Using tooltips with buttons on touch devices

3 replies
Last updated: Feb 16, 2021
Is there an idiomatic way to use Tooltips with buttons?
E.g. the following example is a bit a clunky on a touch device, since tapping the button also shows the tooltip (which just then sticks around) – which can be a bit awkward!
https://www.sanity.io/ui/arcade?mode=jsx&jsx=eJxVT0EOgjAQvPuKTS8ciR48GEoifsEPkLIhja[…]on=A+basic+example+of+using+the+Tooltip+primitive+in+Sanity+UI .
Ideally, I’d like to be able to recreate the behaviour of the existing publish button in Sanity (where you see a tooltip on hover with
fine pointers, but on touch devices / coarse pointers, tapping the button doesn’t reveal the tooltip)
Feb 15, 2021, 12:22 PM
If the tooltip is information that you want both mobile/touch devices and desktop users to have access to, but don’t want to force users on touch devices to open it before performing the action, I would recommend not using a button to trigger the tooltip. It’s not really expected or accessible behavior, if you think about a user’s thought process. If I’m using a mouse and not confident what a button is going to do, I might hover over it for a brief period to see if a title description pops up. On a touch device though, I’m not going to click on a button to get more information about what it does.So first things first, your button probably needs better copy if it’s not clear what it does. Second, if it’s not information a mobile user needs, then is it necessary at all? If it
is information a user on all devices should get, then the ideal pattern would be to have something like an info icon or “help” text that they can hover over to get the tooltip.
Feb 15, 2021, 9:53 PM
It's not baked in to
@sanity/ui
, but you could use the
disabled
property on the
Tooltip
to achieve it (see modified arcade here ). Will consider whether this should be the default behavior 🤔
Feb 16, 2021, 3:18 PM
(Fwiw, this is what the Studio does internally)
Feb 16, 2021, 3:19 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?