QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.83k stars 1.31k forks source link

[✨] Towards atomic CSS in Qwik #4150

Closed wmertens closed 1 year ago

wmertens commented 1 year ago

Is your feature request related to a problem?

Tailwind and style9 are proving that there's something to atomic-ish CSS and CSS-in-JS.

Atomic CSS means (IMHO) that the CSS is broken down into individual rules. To do this, it's easier if you have a ton of mechanically prepared rules.

This means that there will be a lot of rules you don't use, and that it's easy to misspell a classname unless you're helped with types.

Describe the solution you'd like

We want the following properties:

  1. define rules in libraries as well as in-file next to components
  2. definitions compile to static classnames+css at build time
  3. Qwik handles the css injection, whether in one large file or component-by-component
  4. when a classname is not used, its css is not included

To achieve this, we need:

Describe alternatives you've considered

vanilla-extract goes a long way but isn't optimized for atomic css and doesn't tree shake the css

Additional context

It may seem suspect that a special QRL type and special CSS handling is needed, but CSS is an integral part of the browser platform, so IMHO it's warranted to give it special treatment in a framework meant for the browser platform.

manucorporat commented 1 year ago

Let’s close this, as PandaCSS fullfills of this checks!