Replies: 1 comment
-
According to the tailwind 4 docs it says that lightning css flattens the nested CSS: So I'm unsure why this doesnt work then. |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
My understanding was nested selectors are transformed by the css engine to act as if it was apart of the parent rule:
While that works fine for light dom element, it doesn't seem that works when using the
::part()
selector. This makes it annoying to apply a tailwind class that also has a nested hover/focus state. Im using the@utility
directive to generate an interactive-bg-color:On normal elements I can apply it with
<div class='interactive-bg-surface-container'></div>
and it works as intended.Applying that to a shadow dom part does not apply the hover state:
And instead I must apply it separately:
Makes maintenance harder because if I change the surface level of an element I need to remember to update the hover/focus/etc states as well.
I'm curious if this is something tailwind could fix when generating the applied classes and expanding the nested css rules. I'm guessing this is what old versions of tailwind/postcss did to allow development in css but backwards compatibility with older browsers. If I used postcss instead with tailwind 4 would it expand the nested rules?
I did make an issue with csswg to see if this is intended browser behavior but I don't see why the engine shouldn't support that directly.
Beta Was this translation helpful? Give feedback.
All reactions