Answer the question
In order to leave comments, you need to log in
How to correctly set the class?
I use the module.css approach in my work. In order to set a class, I have to write
What should I do if I use hooks and I need to specify several classes?
<div className={styles.tabsContentWrap}></div>
<div
className={
toggleState === 1 ? "tabsContent active-content" : "tabsContent"
}
>
</div>
Answer the question
In order to leave comments, you need to log in
className={`tabsContent ${toggle === 1 ? 'toggle' : ''}`}
styles.tabsContentWrap
resolves to a regular string
primitively you can do this
className={toggleState === 1 ? `${styles.tabsContentWrap} ${styles.activeContent}` : styles.tabsContent}
https://www.npmjs.com/package/classnames
const className = classNames("tabsContent", {"active-content": toggleState === 1});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question