paint-brush
How to use Font Awesome in an Ionic Applicationby@amanhimself
1,530 reads
1,530 reads

How to use Font Awesome in an Ionic Application

by Aman MittalAugust 10th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

There is an element of confusion when it comes to use FontAwesome in an Ionic Application. To include this fonts library in Ionic needs a bit of configuration and this step by step guide will provide just that.
featured image - How to use Font Awesome in an Ionic Application
Aman Mittal HackerNoon profile picture

There is an element of confusion when it comes to use FontAwesome in an Ionic Application. To include this fonts library in Ionic needs a bit of configuration and this step by step guide will provide just that.

Bootstrap an Ionic Application

Create a new Ionic application or you can follow these steps to include FontAwesome in your Ionic application. Nothing will break down.

Now, install the FontAwesome package from npm and save it in the app's dependencies:

Type the above in the root folder of your app. This will add the font-awesome folder under node_modules. The --save option will include the package inside the dependencies section of package.json file.

Include the fonts

Now wander to the src/index.html file and add the following link tag just above build/main.css:

Add a Custom Copy Script

Ionic includes a copy script file that is called during the build process when the command ionic serve executes and it is responsible for moving specific and required resources from node_modules to the www folder such as ionicons.

The location of this script file is under node_modues folder:

Copy this file and paste in inside a new directory called config under the root directory of your Ionic application. Open the file and add fontawesome entries at the bottom of this file.

Include Custom Copy Script in package.json

We must include this custom script inside our package.json file to override the one where we copied the orignal file from. Open the package.json file and add this json code:

That’s it in the configuration part.

Use FontAwesome

To implmenet FontAwesome in this or any Ionic application after the above configuration, we try adding some fonts on our pre-generated home page.

There are more than 675 icons available in FontAwesome and I think a combination of both Ionicons and FontAwesome will be enough for some the applications out there. You can even style them, change their font-size and color as per your needs.

Full source code at this Github Repository

Want to receive more articles like this one? Subscribe me here. Sometimes, I send “never seen before” content to my subscribers.

Find me:


Aman Mittal 🖖 (@amanhimself) | Twitter_The latest Tweets from Aman Mittal 🖖 (@amanhimself). #BookBlogger @ https://t.co/UQvyNf1OTC | Developer | #Nodejs |…_twitter.com