Replies: 1 comment 1 reply
-
|
The <!-- Instead of *:flex (cannot be overridden) -->
<div class="[&>*]:where:flex">
<div class="grid">I can override!</div>
</div>Or create a custom variant: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The documentation makes it clear "children can't override styles given to them by the parent", the reason being that "children rules are generated after the regular ones and they have the same specificity"
On the topic, I find the following issues / PR:
childrenvariant #277childrenvariant #6086*variant for targeting direct children #12551*and**variants #14920 (edit)where I learned several solutions (changing specificity with
:where, making use of@layer) have been considered too, each with their own downside. The above limitation was accepted when the selectors were introduced in v3 as a possibly temporary thing, until the release of v4 (released Jan 2025).Yet, it seems v4 still carries the limitations + I suppose what was a breaking change in v3 has now become a breaking change in v4 too.
AFAICT, nobody has identified a downside to just outputing the children rules before the regular ones, in the sense that it would behave like we expect in every case, and this reordering was mentioned since the very beginning.
For context, I have created an example with descendent, child and state selectors and it really looks to me like ordering the rules is all it takes to get the expected result. The reordering of rules being (I think) the minimal possible change of precedence between rules, it is most likely the safest solution, assuming I am not missing anything.
Beta Was this translation helpful? Give feedback.
All reactions