What’s wrong with CSS-in-JS?
Brad Frost thinks it’s:
- Lack of portability
- Context Switching
- Flushing best practices down the toilet
In the spirit of good-ol-fashioned blog-and-response, here’s:
I’d like to point out that “CSS-in-JS” is an umbrella term, and that there are lots of takes on actual implementations of this. It’s possible to like one approach and not another.
Me, my guess is we’ll end up with a split down the middle as a best practice someday.
When we write styles, we will always make a choice. Is this a global style? Am I, on purpose, leaking this style across the entire site? Or, am I writing CSS that is specific to this component? CSS will be split in half between these two. Component-specific styles will be scoped and bundled with the component and used as needed.