How to use Font Awesome in Angular

In this article, we going to see how to use Font Awesome in Angular application. If you are trying to install Font Awesome in Angular you may have a lot of confusion with the npm modules, So here I provide you the best solution to integrate with your Angular project.
Here we going to use Font Awesome 4.7.0 in the Angular project. Use the below steps to integrate. Before that install Angular App, The best way to create your Angular project using Command Line Interface (CLI), for that here you have an article for installing an Angular app.
Font Awesome with Angular
Step: 1
Use the below npm command to install Font Awesome 4.7.0. in your node_modules
1 |
npm install font-awesome --save |
Step: 2
Now you can import the Font Awesome styles[] array inside the angular.json file, or if you are using an older version you need to import on styles[] array inside the angular-cli.json. Here below you have a reference.
angular.json
1 2 3 4 |
"styles": [ "src/styles.css", "node_modules/font-awesome/css/font-awesome.css" ], |
Note: If you are using an older version add extra ../ on the Font Awesome importing path. For example, use like this "../node_modules/font-awesome/css/font-awesome.css"
Step: 3
It is time to use icons on your Angular project, use the below code in index.html, app.component.html or anywhere in your Angular app to display the icons.
1 2 3 4 5 6 |
<i class="fa fa-university fa-xs" aria-hidden="true"></i> <i class="fa fa-cc fa-sm" aria-hidden="true"></i> <i class="fa fa-check-circle-o fa-lg" aria-hidden="true"></i> <i class="fa fa-clock-o fa-2x" aria-hidden="true"></i> <i class="fa fa-check-square fa-3x" aria-hidden="true"></i> <i class="fa fa-circle-o fa-5x" aria-hidden="true"></i> |
Output:
For more icons Click here .
Conclusion:
I hope this article helped you to integrate Font Awesome in your Angular project. If you like this article, kindly share it with your friends.
Mraj
Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts. If you have any questions let me drop an email with the article name to the following email id: [email protected]