Categories
React Answers

How to use font awesome in a React app?

Spread the love

To use react-fontawesome with React, we run

npm i react-fontawesome

to install the icon packages.

Then we use it by writing

const React = require("react");
const FontAwesome = require("react-fontawesome");

const MyComponent = () => {
  return (
    <FontAwesome
      className="super-crazy-colors"
      name="rocket"
      size="2x"
      spin
      style={{ textShadow: "0 1px 0 rgba(0, 0, 0, 0.1)" }}
    />
  );
};

to add the FontAwesome component into the MyComponent React component.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *