-
In the new version of Tailwind (4), using Hover ('hover:') first checks that the device really supports this effect to apply it or not, which works correctly, but if I try to group it with other utilities this check is not done or it does not apply as expected. I'm not sure if I'm applying this the right way. This is what I have been wanting to group:
Here is an example of what I was trying to group and it didn't work:
Hover only works correctly if I keep it separate:
I just want to have my styles more simplified. Is this the correct way to group these utilities or is there another way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
When you do You could keep them separate as you are now or perhaps make your own variant with @custom-variant foo {
&:hover {
@media (hover: hover) {
@slot;
}
}
&:is(:focus, [aria-current="true"]) {
@slot;
}
} <div class="foo:text-black foo:font-semibold foo:underline dark:foo:text-white"> |
Beta Was this translation helpful? Give feedback.
When you do
[&:is(:hover,:focus,[aria-current=true])]:
, you "lose" the primary pointer check since you've now fallen back to regular CSS.hover:
is not directly analogous to:hover
, since it has the@media (hover: hover)
in it too.You could keep them separate as you are now or perhaps make your own variant with
@custom-variant
: