I'm trying use use a variable in a class name with css modules in nextjs, but I'm having a bad time figuring out the right syntax.
my variable comes from the api:
const type = red
how i'm trying to do it:
<div className={` ${styles.background} ${styles.--type}`}></div>
The result that I expect:
<div className={` ${styles.background} ${styles.--red}`></div>
is there a way to do it?
styles[type]? You seem to be mixing up CSS variables with regular JavaScript variables.