Reputation: 1444
I have a Next.js project and I'm studying using SCSS/SASS for styling. I'm trying to figure out the best way to simplify the class name styling.
So right now I'm having the following problem:
I have a component like:
import styles from './component.module.scss';
const Component = () => {
return (
<div className={styles.container}>
<div className='content'>
...
</div>
</div>
);
}
I would like to make a simple .scss like:
.container {
background-color: red;
.content {
background-color: blue;
}
}
The class .container
works well. But to be able to apply .content
I would have to change the 2nd div's classname to {styles.content}
instead of just content
.
Is there a way to use styles.CLASS
only in the top div of the component and not have to use it for every children's div?
Upvotes: 0
Views: 3464
Reputation: 359
You can Add a Global Stylesheet to app.js, and use it like that everywhere:
<div className='content'> ... </div>
or a module Stylesheet, and use it like that, only in files you imported it
import styles from './component.module.scss';
<div className={styles.container}> ... </div>
if you want it like that:
<div className={styles.container}>
<div className='content'>
...
</div>
</div>
you need to create 2 Stylesheets
Upvotes: 1