Arnas Dičkus
Arnas Dičkus

Reputation: 677

How to add css class and css module on one item?

Currently, in React I write my css in css modules. However, I also use the font-awesome library which uses normal css.

So my question is there is a way to use a normal css and css module on the same selector?

<i className={classes.icon} + "far fa-user" />

Upvotes: 0

Views: 549

Answers (2)

zilijonas
zilijonas

Reputation: 3775

Thanks to ES6 syntax, you can write it like this:

<i className={`${classes.icon} far fa-user`} />

Upvotes: 3

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167182

If you completely understand how React works, you will be putting it this way:

<i className={classes.icon + " far fa-user"} />

The classes.icon will be the className string and along with it, you have to add other classes.

Upvotes: 2

Related Questions