Skip to main content

Hi I need help to upload the font awesome icons and use them in LWC. Please guide me. Thanks

3 Antworten
  1. 21. Apr. 2025, 07:17

    Hi @Muhammad Naveed Nawab

     

     

    Please check this once 

    HTML File:-

    <template>

    <i class="fa-solid fa-bars"></i>

    </template>

    JavaScript File:-

    import { LightningElement } from 'lwc';

    import { loadStyle } from 'lightning/platformResourceLoader';

    import Fontawesome from '@salesforce/resourceUrl/BootstapCDN';

    export default class PortfolioFooter extends LightningElement {

    renderedCallback() {

    Promise.all([

    loadStyle(this, Fontawesome + '/css/all.css')

    ]).then(() => {

    console.log( 'Files loaded' );

    })

    .catch(error => {

    console.log( error.body.message );

    });

    }

    }

    Reference link:-  

    https://salesforce.stackexchange.com/questions/309305/how-to-make-font-awesome-icons-work-on-lightning-web-components

      

     

    Hope this helps  

    Thanks 

     

0/9000