Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emotion: Using both a class and the "css" method in "className" prop

How can both a class plus additional CSS be applied when Emotion is used with the className prop in React?

For example, how can one add a class myClass to the following?

import {css} from 'emotion'

<div className={css`color: red`}>
like image 876
Donald Taylor Avatar asked Nov 05 '25 06:11

Donald Taylor


1 Answers

I've never used Emotion but it looks like you can simply add your class and another template string around the css function.

<div className={`myClass ${css`color: red`}`}>

I tested this with one of their inline editors on a page in their Introduction then checked the markup. Seemed to work.

like image 94
rtmalone Avatar answered Nov 07 '25 05:11

rtmalone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!