I am working with Angular 4 in dev environment (localhost). I installed font awesome via npm and added:
"./node_modules/font-awesome/css/font-awesome.css",
to my styles scripts.
When I check my icon in browser, everything looks fine:
But my icon does not appear on the page, just an empty square. What am I doing wrong?
Make sure you're using the latest and greatest by updating your CDN code reference, updating your Font Awesome package via npm, or downloading a fresh copy of Font Awesome. You can check with version an icon was added to on its detail page (e.g. question-circle was added in Verion 1 but last updated in 5.0. 0).
You can place Font Awesome icons just about anywhere using the CSS Prefix fa and the icon's name. Font Awesome is designed to be used with inline elements (we like the <i> tag for brevity, but using a <span> is more semantically correct). icon If you change the font-size of the icon's container, the icon gets bigger.
make sure you have font-weight: 900 . you are using multiple classes fas fa-github btn btn-dark btn-lg if any of these does not have font-weight: 900 font will not show up. but if you are using fas with some other class like . btn it will over write font-weight: 900 and icon will not display.
You place Font Awesome icons by using the prefix fa and the icon's name.
its working code :
npm install font-awesome --save
add font-awesome link in .angular-cli.json :
"../node_modules/font-awesome/css/font-awesome.css"
in html file
<i class="fa fa-cog fa-spin"></i>
If you're using the free version. Try this..
First Delete fortawesome registry & authToken
npm config delete "@fortawesome:registry"
npm config delete "//npm.fontawesome.com/:_authToken"
Then Install the package
npm install --save-dev @fortawesome/fontawesome-free
After Installing the package, Add below code in your angular.json file
......
"styles": [
......
"node_modules/@fortawesome/fontawesome-free/css/all.css"
],
"scripts": [
....
"node_modules/@fortawesome/fontawesome-free/js/all.js"
],
.....
Note: There were twice of those blocks (styles/scripts). Add to both
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With