DEV Community

Discussion on: Disadvantages of Css-in-Js ?

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

I've never been a fan of putting CSS inside components: usually, there's like 5% of CSS that is truly specific to a component, mostly regarding its internal layout. But most of the CSS of a component tends to be global: link and button styling, font and background colours, etc.

CSS in JS is the type of hammer that turns everything into a nail, thumb and screw alike. It makes it neither easier not more convenient, to overzealously put too much styling inside a component, but it makes it feel "right" more than it actually is.

Encapsulation is almost always good in programming, but styling is one of the rare cases where we should be fighting against that intuition.