Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fontawesome 5 with Angular 2+

I don't know how to include FontAwesome 5 to Angular 2+ app. I found this package - https://www.npmjs.com/package/@fortawesome/fontawesome Could you tell me where should I import this package? Maybe in app.module.ts file?

like image 764
bartekgorski Avatar asked Feb 21 '18 21:02

bartekgorski


People also ask

Is Font Awesome 6 backwards compatible?

Backward Compatibility When Hosting Yourself We've included files to help make Font Awesome 6 easily backward compatible with older versions.

How do I use Font Awesome 5?

To use the Free Font Awesome 5 icons, you can choose to download the Font Awesome library, or you can sign up for an account at Font Awesome, and get a code (called KIT CODE) to use when you add Font Awesome to your web page.


1 Answers

First: you need to install the packages:

$ npm i --save @fortawesome/fontawesome

$ npm i --save @fortawesome/fontawesome-free-solid
$ npm i --save @fortawesome/fontawesome-free-regular
$ npm i --save @fortawesome/fontawesome-free-brands

Then in your app.component.ts you add the imports:

import fontawesome from '@fortawesome/fontawesome';
import faTrashAlt from '@fortawesome/fontawesome-free-regular/';

and in your constuctor of the app.component you add the icon to the fontawesome library:

fontawesome.library.add(faTrashAlt);

In the html page you just add the icon:

<i class="far fa-trash-alt"></i>

Link to fontawesome documentation: https://fontawesome.com/how-to-use/use-with-node-js#free

like image 104
Miss_K Avatar answered Oct 17 '22 17:10

Miss_K