I believe acss.io is the first usage of “Atomic CSS” where the point of it is to be a compiler. You write CSS like this:
<div class="C(#fff) P(20px)"> text
</div>
And it will generate CSS like:
.C(#333) { color: #333;
}
.P(20px) { padding: 20px;
}
(Or something like that.)
The point is that it only generates the CSS that you actually need, because you asked for it, and no more. The result is far less CSS than you’d see in an average stylesheet.
That complication process is what has come to be known as “Just in Time” CSS.
The popular Tailwind framework supports it. It kind of flips the mental model of Tailwind on its head, to me. Rather than providing a huge pile of CSS utility classes to use — then “purging” what is unused — it only creates what it needs to begin with.
I’d say “Just in Time” is a concept that is catching on. I just saw Assembler CSS and it leans into it big time. Rather than classes, you do stuff like:
<div x-style="grid; gap:1rem; grid-rows:1; grid-cols:1; sm|grid-cols:3"> <button x-style="^button:red">Submit</button>
</div>
I’m pretty torn on this stuff. Some part of me likes how you can get styling done without ever leaving your templates. And I especially like the extremely minimal CSS output since CSS is a blocking resource. Another part of me doesn’t like that it’s a limited abstraction of CSS itself, so you’re at the mercy of the tool to support things that CSS can do natively. It also makes HTML a bit harder to look at — although I certainly got over that with JSX inline event handlers and such.