Hacker News new | ask | show | jobs
by ailef 1043 days ago
How do you create reusable styles this way?
2 comments

With components. Same thing as when isolating styles to a component in various frameworks (e.g. Single-File Components in Vue) but instead of its own style tags I just put the styling directly in the HTML.
modern JS has a bunch of half-assed scenarios for solving this problem that allows you to solve almost everything CSS did a few years ago and helps keep people stuck in ineffective legacy ways of doing it because all their code would have to be rewritten to use straight css.

I know because every place I've worked in the last few years uses some form of CSS in JS.

Every five years or so prior to CSS 3, there was a push to purge styling and animation decisions from JS. We are meant to be past that now.

Calling it a feature that you have CSS in your JS is tantamount to saying you’re writing legacy code. Which happens, but don’t be cheerful about it.