Skip to content

The Hover Utility in the new version (4) does not end up working as expected ('only apply when the primary input device supports hover') if you try to group it with other utilities. #16180

Answered by wongjn
UlssCrts asked this question in Help
Discussion options

You must be logged in to vote

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:

@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">

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@UlssCrts
Comment options

@wongjn
Comment options

wongjn Feb 2, 2025
Collaborator

@UlssCrts
Comment options

@wongjn
Comment options

wongjn Feb 2, 2025
Collaborator

@UlssCrts
Comment options

Answer selected by UlssCrts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants