Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import all icons from Fontawesome

I using Fontawesome 5 in my Angular project in this way:

import fontawesome from '@fortawesome/fontawesome';
import { faBold, faItalic, faUnderline } from '@fortawesome/fontawesome-free-solid';

and in contructor:

fontawesome.library.add(faBold, faItalic, faUnderline)

But it's very silly to import each icon separately. Can I somehow import all the icons at once?

upd: import * as icons ... does not work.

like image 545
Vladimir Humeniuk Avatar asked Apr 17 '18 15:04

Vladimir Humeniuk


People also ask

How do you import icons into CSS?

To insert an icon, add the name of the icon class to any inline HTML element. The <i> and <span> elements are widely used to add icons. All the icons in the icon libraries below, are scalable vector icons that can be customized with CSS (size, color, shadow, etc.)

How do I integrate Font Awesome icons in CSS?

To use font awesome icons as CSS content code follow the below steps. Add a unique CSS class name to the icon element you want to use. Set the font-weight css property as 900 (For Solid), 400 (Regular or Brands), 300 (Light for pro icons). Set the content css property to the unicode value font awesome icon.


1 Answers

import { fas } from '@fortawesome/fontawesome-free-solid';

and then

fontawesome.library.add(fas)

same for other styles

import { fab } from '@fortawesome/fontawesome-free-brands';
import { far } from '@fortawesome/fontawesome-free-regular';
...
fontawesome.library.add( fab, far );
like image 162
sr9yar Avatar answered Oct 01 '22 05:10

sr9yar