Disable ToolTips on touch device #1181
-
I would love to know if there is a way to disable tooltip on touch screen devices.. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There are a couple ways to achieve this. The first would be to use a CSS media query to add @media (hover: none) {
.react-tooltip {
display: none;
}
} Here I'm using the 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 search for), and return Feel free to add some more details for your use-case, but hopefully one of these two methods works for you. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot mate. |
Beta Was this translation helpful? Give feedback.
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: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 thepointer: 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…