by Sai gowtham

How to include a Font Awesome 5 icons in React

Font Awesome is a toolkit that provides us different types of icons and social logos.

In this tutorial, we are going to learn about how to include the font awesome icons as components in React.

Installing react-icons package

First, we need to install a package called react-icons. which helps us to use the font awesome icons as a React components.

Run the following command to install the package.

npm install react-icons

Using Font Awesome icons

In this example, we are using Airbnb icon in the App.js file.

App.js
import React from "react";
import { FaAirbnb } from "react-icons/fa";
export default function App() {
  return (
    <div className="App">
      <h1>Hello Airbnb</h1>
      <FaAirbnb size={44} color="green" />    </div>
  );
}

In the above code, we first imported the FaAirbnb component from the react-icons/fa package then included it inside the App component.

Now, we can see the Airbnb svg icon is rendered on the screen.

react airbnb font awesome icon

Have you seen our icon has a green color because we added color to the <FaAirbnb> component by using color prop.

Similarly, you can include all Font Awesome icons by importing as react components.

For icon names, you checkout react-icons website.

Top Udemy Courses

JavaScript - The Complete Guide 2020 (Beginner + Advanced)
JavaScript - The Complete Guide 2020 (Beginner + Advanced)
26,545 students enrolled
52 hours of video content
View Course
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
221,520 students enrolled
44 hours of video content
View Course
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
Vue JS 2 - The Complete Guide (incl. Vue Router & Vuex)
114,575 students enrolled
21 hours of video content
View Course