It seems like CSS Layers are pretty much overlooked and underused. π€
Are you using CSS Layers?
Are you using CSS Layers?
Comments
So no, not yet but Iβm very curious now! Does it work on every browser?
It's looks like CSS-in-JS, but it's more of a TS to css.module preprocessor, kinda.
https://boomer-css.juchereau.com/
Am I reading this correctly, and your use cases are in WordPress? π
Do you usually work with Svelte and Vue? π
Having a @demo layer to single out the relevant code you want to showcase is so useful. π
We found that specificity and source order are more nuanced tools giving us more detailed control.
Did you find any additional/specific drawbacks and challenges that pushed you to stop using them?
Using the double attribute to get a double class specificity.
When layered as "reset, base, components, ..." we found that components with ".foo { display: grid }" are always visible even when they have the "hidden" attribute.
This is just one example, but the most straightforward to explain.
Having full control/ownership over all styles we find that we don't need layers.
Nothing really wrong with using layers, it's more that we don't need them while also experiencing some drawbacks.
So not using cascade layers is a better fit for us.
@import url layer(layer-name);
Also, there is a proposal to add a "layer" attribute for the tag, but I don't think this has been implemented in any browsers yet. π
During my latest attempt, I found the CSS-in-JS solution from our third-party component library is effectively incompatible. I burned a lot of time writing plugin that would wrap its CSS output in a layer to no avail.
Did you try with @import? And would a layer attribute for the tag help with your use case?
Emotion.js is under the hood. I was able to build a rudimentary plugin to wrap the styles with @layer, but only some appended styles were affected.
https://fokus.dev/tools/css-boilerplate/
Do you have any specific tricks, tips, or hacks for cascade layers? π
Do you have any specific examples? π
(Or if you wanna know that beforehand, just ping me via DM and Iβll send you the draft!)