Skip to content

Disable ToolTips on touch device #1181

Closed Answered by gabrieljablonski
devWithKD asked this question in Q&A
Discussion options

You must be logged in to vote

There are a couple ways to achieve this.

The first would be to use a CSS media query to add display: none to the .react-tooltip class (this is the default class for the tooltip). Something like this might work:

@media (hover: none) {
  .react-tooltip {
    display: none;
  }
}

Here I'm using the hover: none media query (which should be fine for what you're asking), but you should read up on other media queries, since there might be one more appropriate for your specifications. For instance, there's also the pointer: coarse query.


The other way (less elegant) would be to have your own wrapper component for the tooltip that detects if it's a touch device (plenty of JS solutions you can sea…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by devWithKD
Comment options

You must be logged in to vote
1 reply
@gabrieljablonski
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants