Re: [csswg-drafts] [css-cascade-5] Allow authors to explicitly place unlayered styles in the cascade layer order (#6323)

I was thinking regarding the “should every layer have its override (and possibly defaults) layer?”, and there are valid use cases for both having a way to place something before/after everything in some layer, _and_ having a way to put something before or after globally.

So, we have several different cases:

1. An ability to place something **after** the unlayered styles inside any layer, something like an `!overrides` layer.
2. An ability to place something **before** the unlayered styles inside any layer. As Tab says, it _is_ possible to set it up right now, but I can see use cases where you could want to do it without this setup, like when importing some external library, and wanting to insert the styles in a specific place.
3. An ability to place something **before everything** or **after everything** regardless of the layer structure. I can see how this could be useful, but I think this is a separate issue (or two), and I am not entirely sure if this should be a part of _layers_ specifically, or something else. If we were to make it a part of layers, I'd propose something like `@layer-root` which will basically be a way to access layers _absolutely_. The `@layer` right now is relative, and append-only. With something like `@layer-root !overrides` you could set the styles to the overrides of the root layer, for example, regardless of how your code is nested. This could also allow us to escape any layer and add styles to any layer if we know the “path” to it from the root one.

But I would suggest us to focus on the **1** in this issue, and create separate ones for **2** and **3**. I think all of these have valid separate use cases, but **2** is more of a “good to have”/“syntax sugar”, and **3** needs more thoughts (should it be `@context` like in https://github.com/w3c/csswg-drafts/issues/10094#issuecomment-2179369415? Should it be possible with `@layer-root` or something else? Do we even want something like this? Etc).

Outside the bikeshedding of the `!overrides` naming and questions over how exactly do it works, I think we can resolve on _adding **1**_, then discuss what should be the preferred syntax for it separately, but also taking into consideration the potential syntaxes for **2** and **3** for things to be consistent.

-- 
GitHub Notification of comment by kizu
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6323#issuecomment-2213627496 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 8 July 2024 10:24:23 UTC