Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular-fontawesome 5 icons with primeng 7 or Angular 2+

I have followed the instructions to use svg icons of angular-fontawesome 5 icons. Please find the link below

https://www.npmjs.com/package/@fortawesome/angular-fontawesome

As a first step

npm i --save @fortawesome/fontawesome-svg-core 
npm i  --save @fortawesome/angular-fontawesome 

If I am correct to use the brand icons

npm i --save @fortawesome/free-brands-svg-icons

Step two: In app.module.ts file: Imported the following

import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
import {fab, faFacebookSquare, faGoogle} from '@fortawesome/free-brands-svg-icons';

Step three: As per the primeng documentation I want to use the brand icons inside the button.

<div class="center-text">
 <p-button icon="fab fa-google" label="Click"></p-button> 
</div>

No errors in the console. But couldnt see the icon in display.

As an alternative way:

  <div class="center-text">
  <i class="fab fa-google"></i>
   <p-button label="Click"></p-button>
  </div>

Still no output. Kindly help how to bring the brand icons inside the primeng buttons.

like image 324
Ragavan Rajan Avatar asked Jan 22 '19 21:01

Ragavan Rajan


People also ask

How do I use Font Awesome 5 icons?

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.

Is Font Awesome 6 backwards compatible?

Backward Compatible by Default! If your project uses Version 5 icons, style names, or custom CSS rules with Font Awesome @font-face rules, your Kit will automatically update icons to use Version 6!

Is Font Awesome heavy?

Although Font Awesome is the most popular icon font, many web developers don't use it because of its excessive size. The default minified resource size of Font Awesome (4.7. 0) is 110 KB and it can be a lot bigger than that depends on which font source is in use.


1 Answers

To use Font Awesome together with PrimeNG you need to use the standard fontawesome package, not angular-fontawesome.

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

And in your angular.json file:

"styles": [
    "node_modules/@fortawesome/fontawesome-free/css/all.min.css",
    ...
],

See https://forum.primefaces.org/viewtopic.php?t=56786 for more information.

like image 73
Peter Wretmo Avatar answered Nov 15 '22 07:11

Peter Wretmo