-
We're using named peers to differentiate several checkboxes, e.g. <input type="radio" name="menu" class="peer/foo hidden" />
<input type="radio" name="menu" class="peer/bar hidden" /> We then want to style some sibling elements using the named variants of <input type="radio" name="menu" class="peer/foo hidden" />
<div class="peer-checked/foo:hidden"> However, we also want to style descendant elements based on the named peer, e.g. <input type="radio" name="menu" class="peer/foo hidden" />
<div class="group">
<div class="group-peer-checked/foo:hidden"></div>
</div> The issue here is that Tailwind CSS 4 seems to interpret .group-peer-checked\/foo\:hidden:is(:where(.group\/foo):is(:where(.peer):checked ~ *) *) Instead of the following as I'd expect: .group-peer-checked\/foo\:hidden:is(:where(.group):is(:where(.peer\/foo):checked ~ *) *) I suppose this is an ambiguity in the class name as it isn't really possible to figure out whether Is there a way to make this unambiguous? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The <input type="checkbox" name="menu" class="peer/foo" />
<div class="group">
<div class="group-[&:is(:where(.peer\/foo):checked_~_*)]:hidden">
Hello World
</div>
</div>
|
Beta Was this translation helpful? Give feedback.
Thank you for these detailed suggestions, @rozsazoltan.
I ended up going with a slight variation of your recommended approach:
As we only have one
group
, there's no need for named groups but we can still use the arbitrary selector and the subsequent sibling combinator to only make the innerdiv
hidden when its group follows the checked, named peer checkbox.