Home > OS >  Using font awesome styles in react
Using font awesome styles in react

Time:11-11

I am not a front end developer so this is I guess a newbie question.

I have developed a first version of my react app where I use semantic css I have installed the package then imported it in my index.js file :

import 'semantic-ui-css/semantic.min.css';

This has allowed me to syle my components with semantic CSS and it works fine.

Now for my second version I would like to add fontawesome, so i did the same I installed the packages required :

npm i --save @fortawesome/react-fontawesome
npm install --save font-awesome

And imported the package again in index.js

import 'font-awesome/css/font-awesome.min.css';

However this does not style my components with fontawesome classes :

Example :

class CardButton extends React.Component {
  render() {
    return (
      <button className="button button-primary">
        <i className="fa fa-chevron-right"></i> Find out more
      </button>
    );
  }
}

export default CardButton;

this does not get styled

CodePudding user response:

you would need to import this too, try to import them too, then it will work for sure, you missing out importing dependencies,

import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap/dist/css/bootstrap.css';
import 'font-awesome/css/font-awesome.min.css';
  • Related