DEV Community

Discussion on: How to isolate component styles in React using CSS modules

Collapse
 
link2twenty profile image
Andrew Bone

Interesting read, currently I've been using BEM but I'd be interested to experiment with this.

Does it cope with pseudo selectors, media queries and more advanced features like subsequent-sibling combinators?

Collapse
 
eransakal profile image
Eran Sakal • Edited

Hi,
Thanks for reading. css module library has its limitations. Some things fit nicely into the css modules design, for example, tip #7 that lets you set :global selectors under you component selector. It also lets you handle nesting in .scss by flatting their names when exporting them as a javascript object. But since it must flat the list of selectors, you "lose" some flexibility and some features.

I recommend you to give css-in-js a try, I'm using it in large scale projects and can do everything you mentioned and even more because you can use javascript to perform calculations or manage a theme at runtime.

Thanks Again :)