DEV Community

loading...

Discussion on: CSS in JS - have we done something wrong?

Collapse
malikbagwala profile image
Malik Bagwala

I agree partially to this blog post. I will try to state my points clearly.

  1. Yes, CSS in JS (assuming styled-components here) is big pain point when it comes to styling smaller projects since it adds the unnecessary boilerplate or defining components for small style changes(margin,padding...etc)

  2. The benifits of CSS in JS really kick in when the application scales! Rather than having to put in a dozen of styles (intent, size,color,shape etc. you get the point) you can have the component adjust to props instead!

  3. Also themeing is a major reason to choose CSS in JS because you can have a root level variable map with different values rather than having to maintain a million classes!.

  4. All the styling is local, so there is no situation for style conflicts.

To conclude, CSS in JS is unncessary and more often annoying to style small apps, but the benefits really kick in for large web apps that have a complex design system in place(custom components, themeing, reusability etc)

PS. these are my 2 cents on the topic, yours may wary and I respect that.