HomeAbout Me

Use Font Awesome Angular Component in 5 simple steps

By Sri Gunnala
Published in Front End
May 05, 2022
1 min read
Use Font Awesome Angular Component in 5 simple steps
Fontawesome is most popular icon tool kit. It has 1500+ free icons. Most importantly these icons are created using scalable vectors and automatically inherit CSS size and color. This means they blend in with text inline wherever you put them. This makes it high-quality icons that work well on any screen size.

Before Angular 5, we had to install a font-awesome package and reference its CSS. Now we have an angular component for fontawesome which makes it simple, clean and neat.

Below are the five simple steps to add fontawesome components into your angular application.

You can download the source code from here

  1. Create a new angular app. And remove the whole code in the ‘app.component.html’ file. We don’t need this as we just want to see how to use it.
ng new angular-fontawesome
  1. Install fontawesome angular components
npm install @fortawesome/fontawesome-SVG-core
npm install @fortawesome/free-solid-svg-icons
npm install @fortawesome/angular-fontawesome
  1. Import FontAwesomeModule into app.module.ts

Font Awesome Angular Component
Font Awesome Angular Component

  1. Import the icon you want to use into component

Font Awesome Angular Component
Font Awesome Angular Component

Identifying font classes is very easy.

class name ‘fa-home’ converts to fame

class name ‘fa-long-arrow-alt-left‘ converts to faLongArrowAltLeft

  1. Add the icon in the component HTML file.
<fa-icon [icon]="home"></fa-icon>

Compile and run it.

Font Awesome Angular Component
Font Awesome Angular Component


Tags

#angualr
Previous Article
What is Deno.js and how it is different from Node
Sri Gunnala

Sri Gunnala

Learner | Reader | Blogger | Azure Enthusiast

Topics

Front End
Microsoft Azure
Microsoft .NET

Newsletter

Sri Gunnala - Make sure to subscribe to newsletter and be the first to know the news.

Related Posts

What is Deno.js and how it is different from Node
May 05, 2022
3 min

Legal Stuff

Privacy NoticeCookie PolicyTerms Of Use

Social Media