Using Scss global styles + modules - How To (with the newest NextJS built-in support)? #15114
-
Hi, I sticked to the instructions on how to use scss.
with the
This is the global style. Now the same principle for a module:
with
That's all there is to my project.
What am I missing? It is probably something obvious, since I am new to frontend developing. Also, I haven't configured anything in this project so far. ============================================================================ Out of the context side question: Is it possible to directly apply styles to the
and
but I think that is not possible, it is? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
That error is occurring because you are importing You must always use a selector with CSS modules. So if you want to apply styles to <div className={styles.wrapper}>
<nav> .wrapper {
nav {
// styles
}
} |
Beta Was this translation helpful? Give feedback.
That error is occurring because you are importing
global.scss
intoNavBar.module.scss
. SCSS/CSS modules cannot have element selectors in the top level like that.You must always use a selector with CSS modules. So if you want to apply styles to
<nav>
you would have to give it aclassName
. The only alternative would be if you had a wrapping element you applied a class to: