logoalt Hacker News

eudamoniactoday at 4:42 PM1 replyview on HN

It is used because UI component frameworks make vanilla CSS an awkward an unnecessary tool (the Cascading part). CSS makes sense as designed for styling a document, but not so much for styling atomic components. If we were designing the web and CSS from scratch around the React model, CSS would not be made to cascade, because that is totally unnecessary and usually leads to more issues than it solves. Apart from theme variables, in a component system there's no reason to have global CSS anywhere; you'd just style each component in isolation. So when in the React model you typically want no cascades at all, the library that is made for that gets popular.

CSS modules are also a solution to the above, but, once you get rid of cascading, and you have one stylesheet per component, it is again unnecessary to have the one stylesheet in a different file from the one component. There's no benefit to splitting a component and its styles into two files; it just makes it more annoying to edit. So we move the styles essentially inline, with either Tailwind or CSS-in-JS.


Replies

sassbadgertoday at 5:40 PM

Thanks for this great explanation of your viewpoint. As an occasional frontend dev who really got into Tailwind, it was always hard for me to explain why I'm so much more productive in Tailwind than in writing CSS. This makes a lot of sense.