Why I Write CSS in JavaScript
I&#x27;m unconvinced.<p>For one thing, it&#x27;s not CSS in Javascript... there&#x27;s no cascade and no sheet, so it&#x27;s just &quot;styles in Javascript&quot;. (And, actually, this article is only about a specific implementation.)<p>The benefits listed are:<p>- &quot;confidence&quot; - but I think that&#x27;s a matter of understanding and mastering the tool, whether it&#x27;s CSS or this library. As the co-creator of &quot;styled-components&quot; the author is no doubt a master of it. For for the general developer, perhaps a roughly equal effort would provide a similar level of mastery in each. So why not invest in the standard?<p>&quot;Painless Maintenance&quot; - I would have to use it deeply before I could say too much about this. But I would guess that the danger of creating spaghetti code and a spaghetti of .css are pretty much the same and have the same root causes.<p>&quot;Enhanced Teamwork&quot; - I don&#x27;t see the connection here. The discussion in this section seems to be about mastery of the tools again. The team can learn how to manage styles though CSS-based techniques or they can learn through techniques based on coding Javascript and the capabilities of this library.<p>Not that CSS doesn&#x27;t have its issues. IMO, it&#x27;s too low-level to use directly for many cases. There are two main problems:
(1) missing the tools to manage complexity, like scoping, variables, and modules. (2) allows you a lot of freedom to do bad things. But there are libraries that address these that don&#x27;t throw out the fundamental design of CSS, as styles-in-code does.<p>To me it seems like a better approach to build on CSS to address its weaknesses rather than throw it out.<p>The design of CSS itself came out the recognition that the tight coupling of style and content has drawbacks, and this is signing back up for those drawbacks. And you better neatly divide your presentation code from your business logic code and data access code or you&#x27;ll get all that coupled tightly as well.<p>I&#x27;m not dismissing this out-of-hand -- I haven&#x27;t dug into styles-in-code approach so I don&#x27;t have a deep understanding of it.<p>But I&#x27;m not convinced it&#x27;s worth the time to look more closely at it. Really, not even close.