Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use font awesome 5 installed via NPM

Tags:

I am not finding any docs for what to do next, I installed into my project via npm,

$ npm install --save @fortawesome/fontawesome-free-webfonts

But now what? Can anyone point me to how to actually import or use it now? Thank you.

like image 553
thatryan Avatar asked Jan 04 '18 20:01

thatryan


People also ask

How to install Font-Awesome with npm?

Install font-awesome using npm. This is the most maintainable way as npm update will refresh the dependencies for you. Adjust your paths to account for where scss file is located in your project: You can also use a shorter syntax using tilda (~) prefix:

How do I install Font Awesome in angular?

Font Awesome has an official Angular component. npm install --save @fortawesome/fontawesome-svg-core npm install --save @fortawesome/free-<type>-svg-icons npm install --save @fortawesome/angular-fontawesome Note: Replace <type> with solid, brands or regular whatever type of icons you need. You can also install Vue and React components.

How to use Font Awesome in web applications?

There are many ways we can use font awesome in different types of applications. This package allows customizing the styles of icons. using cdn always has advantages for smaller files, It is simple to include in web HTML pages In html pages, Add the below all.min.css file in link tag inside head tag

How to customize the styles of icons in fontawesome?

This package allows customizing the styles of icons. using cdn always has advantages for smaller files, It is simple to include in web HTML pages In html pages, Add the below all.min.css file in link tag inside head tag In nodejs applications, fontawesome provides packages with npm or yarn package managers.


1 Answers

First install it using NPM :

npm install @fortawesome/fontawesome-free --save-dev 

Now you have two ways, one way is to embed the absolute URL within your HEAD section or if you working with something like SASS(SCSS), You can import it in your custom.scss file like this :

1- first set an absolute path for webfonts (It has to be set before the fontawesome.scss) :

$fa-font-path: "node_modules/@fortawesome/fontawesome-free/WebFonts" !default; 

2- Then import fontawesome.scss :

@import "node_modules/@fortawesome/fontawesome-free/scss/fontawesome"; 

3- Finally import regular, solid or light(pro version) of icon types :

@import "node_modules/@fortawesome/fontawesome-free/scss/regular"; 

After all you can assign font-family to these classes to work :

.fa,.fas,.far,.fal,.fab {   font-family: "Font Awesome 5 Free"; } 
like image 199
Hamed Avatar answered Sep 24 '22 10:09

Hamed