CssSyntax error: Selector "&:hover" is not pure (pure selectors must contain at least one local class or id)
See original GitHub issueThe error
./pages/index.module.css (./node_modules/css-loader/dist/cjs.js??ref–5-oneOf-2-1!./node_modules/postcss-loader/src??__nextjs_postcss!./pages/index.module.css) CssSyntax error: Selector “&:hover” is not pure (pure selectors must contain at least one local class or id) (4:3)
color: pink;
&:hover {
color: purple;
}
To Reproduce
https://github.com/andrasna/hello-next-css-module-issue
The above repository is based on following the examples in the documentation:
https://nextjs.org/docs/basic-features/built-in-css-support#adding-component-level-css
Expected behavior
As far as I understand, the above selector does contain a “pure selector”, so it should work. However, apparently, since hover is nested in this example, it isn’t recognized as a “pure selector”.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Selector ":global .class" is not pure (pure selectors must ...
You need to use global selector inside your local selector in CSS-modules. For example, if you have HTML: <div className={classes.
Read more >syntax error: selector "body" is not pure (pure selectors must ...
You can't use body selector in a module as it says in the error message: "Selector "body" is not pure (pure selectors must...
Read more >CSS selectors - CSS: Cascading Style Sheets - MDN Web Docs
CSS selectors define the pattern to select elements to which a set of CSS rules are then applied.
Read more >THAT @REM SHOW on Twitter: "Oh…so, this isn't really CSS ...
CssSyntax error : Selector "&:hover" is not pure (pure selectors must contain at least one local... The error ./pages/index.module.css (./node_modules/css-loader ...
Read more >Documentation - Sass Tutorial
Sass supports a special type of selector called a placeholder selector. These look like class and id selectors, except # or . by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
it didn’t work for me.
Exactly as per https://github.com/zeit/next.js/issues/10475#issuecomment-583898332