-
I'm looking at the output of the official babel + PostCSS plugin, and don't yet understand why are CSS layers needed? (or their polyfilled alternatives). I mean, for example, why does margin-bottom need to be limited to priority5? The more important question is, how can I combine this with my non-StyleX styles, like reset, etc.? My idea is to insert this at the beginning of the file:
This line will override the StyleX generated layer list later on, so it allows me to use a base layer for all my non-StyleX parts. But the layer generation isn't yet clear to me yet. I've noticed the following:
Can you confirm if this is by design? So in theory I could just keep the layer declaration line from StyleX and reuse priority1 for my own rules? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
yes you could do this, but StyleX may output styles within that layer. It depends on what styles exist. the layers exist to ensure that various different styles have the right specificity. We need margin-top to win over margin for example. But in practice things are more complex as we account for pseudo-classes and at-rules and combinations of them alongside shorthand’s and longhand’s. For reset styles, you can wrap them in your own layer and ensure they’re inserted on the HTML page before the StyleX styles. |
Beta Was this translation helpful? Give feedback.
That is my understanding too