You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"
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.
From the wording of the documentation, it looks like the children classes appearing below the regular classes is a deliberate decision, even though the first message I found, 6 years before the PR, clearly mentions it should be the opposite. I wonder what the rationale was to do it the "incorrect" way?
Is there any workaround for the generated CSS to allow override of a children rule? Maybe a selector I missed?
Is the reordering of rules something that is being considered, especially if the answer to 2. is "No"?
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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
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 #12551where 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