Skip to content

Mobile access for HoverCard and Tooltip (touch has no path to reveal them) #3885

Closed

Description

@cixzhang

Summary

HoverCard and Tooltip are only reachable via mouse hover / keyboard focus today. On touch devices there is no way to reveal them:

  • useHoverCard binds only mouseenter / mouseleave / focusin / focusout. On a phone/tablet there is no primary hover, so uncontrolled HoverCards effectively never open (short of a controlled open prop wired up by the consumer).
  • useTooltip goes further and deliberately suppresses itself on touch: handleMouseEnter early-returns when window.matchMedia('(hover: none)').matches, because the emulated hover would otherwise eat the tap. So a plain Tooltip shows nothing at all on mobile.

Net effect: any information conveyed only through a HoverCard/Tooltip is invisible to touch users. We should define and ship a first-class mobile activation path.

Proposed direction (to be scoped)

Initial instinct is long-press to reveal on touch. It's a common convention, keeps a single tap free for the trigger's primary action, and doesn't require an always-visible affordance. But long-press carries real tradeoffs — especially accessibility — that need to be teased out before we commit. Capturing the research below so the scoping conversation starts from evidence, not vibes.

AX and UX concerns with long-press specifically

  1. Screen-reader gesture conflict. Long-press is not a screen-reader-native gesture. Under VoiceOver / TalkBack the touch model changes entirely (explore-by-touch, double-tap to activate, swipe to move focus), so a raw touchstart+timer long-press won't fire the way it does for sighted touch users. Whatever we build must also expose the content through the accessibility tree (e.g. aria-describedby on the trigger so the SR announces it), independent of the long-press gesture. Long-press alone would leave SR users with no path — arguably worse than today because it looks solved.
  2. Discoverability. A long-press affordance is invisible. Sighted touch users have no cue that content is hidden behind a press-and-hold. HoverCard already supports a dashed-underline hover indication; we'd want an equivalent, touch-appropriate affordance (or lean on the trigger being an obviously-interactive element).
  3. Gesture collisions. Long-press already means "select text / show context menu / magnifier callout" on iOS and Android, and browsers fire the contextmenu event. We'd need to manage -webkit-touch-callout, user-select, and contextmenu carefully so we don't break native selection or double-fire.
  4. Timing & motor accessibility. Press-and-hold thresholds are hostile to users with motor/tremor conditions and to WCAG 2.5.x expectations around timing. If we require a hold, the duration must be reasonable and ideally not the only way in.
  5. Dismiss / persist / hoverable (WCAG 1.4.13). Content on hover-or-focus must be dismissable, persistent, and hoverable. The touch equivalent needs an explicit dismiss (tap-outside / close affordance) and must not vanish on an incidental touch-move.

What's in the wild

  • @media (hover: none) / (pointer: coarse) is the standard signal for "no reliable hover" — already used in the Tooltip suppression logic. This is the right gate for any touch-specific behavior. (CSS Media Queries L4 interaction media features.)
  • Tap-to-toggle is the most common non-hover pattern: first tap reveals, tap-outside/second interaction dismisses. Simpler and more discoverable than long-press, but it competes with the trigger's own click/navigation action — fine for a bare info icon, problematic when the trigger is itself a link/button.
  • GitHub hovercards solved the keyboard path (focus + dismiss) but hovercards there are still largely a pointer affordance; the lesson is that the accessible fallback is a separate, explicit mechanism, not the same gesture.
  • Guidance is consistent that tooltips must not be the sole carrier of essential info, and that content-on-hover must satisfy WCAG 1.4.13 (dismissable / hoverable / persistent). Deque/USWDS/Tippy.js all land here.

Open questions for scoping

  • Long-press vs tap-to-toggle vs "trigger becomes a real button that opens a popover on tap" — likely differs between Tooltip (presentational, short text) and HoverCard (richer, potentially interactive content).
  • For Tooltip specifically: is the right mobile answer to not try to show it on touch at all, and instead require essential info to live elsewhere? (i.e. is the current suppression actually correct, and the bug is only that we don't document/enforce the "don't hide essential info in a tooltip" rule?)
  • Do we need a shared primitive (a useTouchReveal gate keyed on (hover: none)) so HoverCard and Tooltip behave consistently?
  • What's the accessible-tree contract regardless of gesture (aria wiring so SR users always get the content)?

Acceptance criteria (draft)

  • Decision recorded on the mobile activation model for Tooltip and for HoverCard (may differ).
  • Whatever gesture we pick, the content is also exposed to assistive tech independent of the gesture.
  • Behavior gated on @media (hover: none) / coarse pointer so desktop is unaffected.
  • Satisfies WCAG 1.4.13 (dismissable, persistent, hoverable-equivalent) and doesn't break native text selection / context menu.
  • Story + docs showing the mobile interaction.

Filed for scoping — the long-press instinct is a starting point, not a decision. Needs design review before build.

Activity

  1. added
    enhancement
    component
    design
    needs-scoping
    needs:design-review
    on Jul 12, 2026
  2. mohityadav8 commented on Jul 12, 2026

    @mohityadav8

    @cixzhang can i work on this

  3. cixzhang commented on Jul 12, 2026

    @cixzhang
    ContributorAuthor

    @mohityadav8 thanks for the eagerness :) At the moment though, I'm not sure what the right solution is here. Curious if you've had experience with behaviors like this in the wild and what's worked well. For our internal tools, we've been mostly desktop focused, so these mobile behaviors are still very exploratory for us.

  4. gonzoblasco commented on Jul 16, 2026

    @gonzoblasco
    Contributor

    Great write-up — the long-press vs tap-to-toggle tradeoff is exactly the right conversation to have early.

    A few thoughts from working on accessible component libraries:

    On the hybrid approach: I think the right answer depends on the trigger type, not a one-size-fits-all gesture:

    • Triggers with a primary action (a button that also has a tooltip): long-press makes sense as the secondary gesture, since the primary action owns the tap. This is what native OS tooltips do on mobile.
    • Triggers without a primary action (an info icon, a hovercard target that's purely decorative): tap-to-toggle (toggletip pattern) is better — more discoverable, no timing issues, and aligns with WCAG 2.5.3 (Label in Name) since the trigger is an explicit button.

    On the screen reader concern (point 1): this is critical and often overlooked. Whatever touch gesture we pick, the content must also be exposed through the accessibility tree independently. Using aria-describedby on the trigger is the most reliable path — the screen reader announces the tooltip content when the user focuses the trigger, without needing any gesture at all. This also satisfies WCAG 1.4.13's "persistent" requirement since the content is in the accessibility tree regardless of interaction state.

    On discoverability (point 2): for long-press, a subtle visual affordance helps — like a dotted underline on the trigger text (GitHub hovercards do this well) or a small chevron/ellipsis indicator. For toggletap, the trigger being a focusable <button> with a cursor change is usually sufficient.

    On WCAG 1.4.13: worth noting that the "dismissable" requirement means a tap-outside or Escape key must close the tooltip. For long-press, this is trickier because the user didn't explicitly "open" anything — they held, and content appeared. A tap-outside dismiss works, but the user might not know they need to dismiss. Toggletip is cleaner here: the user tapped to open, so tapping again or tapping outside to close is intuitive.

    On timing (point 4): if long-press is used, the duration should be configurable (300-800ms range) and should not be the only path — keyboard focus plus aria-describedby must always work as a fallback.

    Happy to help test whatever direction you settle on.

  5. gonzoblasco commented on Aug 3, 2026

    @gonzoblasco
    Contributor

    @cubernetes not sure if you've landed on an answer yet, but this is the kind of problem I've been spending too much time on, so I want to push on the specifics.

    I think the trap here is treating Tooltip and HoverCard the same — they're different problems.

    On Tooltip: I'm leaning toward less, not more. Right now useTooltip suppresses on (hover: none) and that's arguably correct. Tooltips are for transient hint text (icon labels, truncated values), not for information users might need to read. If the design system actively forbids putting required content in a tooltip (docs + lint rule + composition-only API), the mobile problem disappears because there's nothing essential being hidden. The current behavior becomes a feature, not a bug.

    The win we give up: better touch discoverability for presentational tooltips. But that's a UX nice-to-have, not a correctness issue.

    On HoverCard: this is where the work is, because HoverCard content is often interactive (commit refs, user bios, link previews). Here I'd propose toggletip, not long-press:

    • First tap opens, second tap (or tap-outside, or Esc) closes. No timing, no gesture collision with text-selection or context menus.
    // Sketch — assumes a Popover primitive already exists
    const useTouchReveal = (open, setOpen, triggerRef) => {
      const isTouch = useMedia('(hover: none) and (pointer: coarse)');
      return useEffect(() => {
        if (!isTouch || !triggerRef.current) return;
        const el = triggerRef.current;
        const onClick = e => {
          // don't hijack if the user actually meant to activate the trigger itself
          const interactive = e.target.closest('a, button');
          if (interactive && interactive !== el) return;
          e.preventDefault();
          setOpen(o => !o);
        };
        el.addEventListener('click', onClick);
        return () => el.removeEventListener('click', onClick);
      }, [isTouch, triggerRef.current]);
    };

    The interactive check matters — a HoverCard wrapping a link shouldn't swallow the link's navigation. That's the trap with naive tap-to-toggle.

    The accessibility contract that has to hold regardless of gesture is the part I want to nail. Whatever activation model we pick, the content has to be reachable through the a11y tree independently. Two mechanisms, both cheap:

    1. aria-describedby on the trigger pointing at the HoverCard content's id. Screen reader users get the content announced when they focus the trigger — no gesture needed.
    2. An explicit Escape handler + a visible close affordance inside the card. This satisfies WCAG 1.4.13 (dismissable).

    If we did this, the gesture question becomes mostly about sighted touch UX. Screen reader users get content through aria-describedby either way. Keyboard users already work. Sighted mouse users already work. We're only solving for sighted-finger-without-hover, which is the smallest population — so erring on the simple, debuggable side (toggletip) over the clever side (long-press) seems right.

    What I'd push back on for the long-press instinct specifically:

    • It looks "native" on Android (text-selection long-press) but it always conflicts with native selection. Try it on a date in a Table cell and you've broken copy-paste.
    • It's invisible — no discoverability for sighted users.
    • It's hostile for users with motor impairments. Even at 500ms it's a barrier. WCAG 2.5.x explicitly frowns on this.
    • iOS Safari fires contextmenu on long-press, which means you also have to suppress that or you double-handle.

    Worth noting: GitHub's hovercards ship the exact pattern I'm proposing here (toggletip on focus + dismiss button), and their docs explicitly call out that hovercards are not the primary navigation path — that's the link itself. That's the model we should be amplifying, not inventing around.

    If this direction is interesting, I can sketch the API + a reference implementation + tests covering:

    • touch (hover: none) path opens on tap, closes on tap-outside / Esc
    • keyboard focus path unchanged from today
    • screen reader path announces via aria-describedby without gesture
    • doesn't break text selection / context menu on the inner element
    • doesn't hijack link navigation when HoverCard wraps an anchor

    Happy to take this as a draft spec + PR if it's useful. Also happy to be wrong about any of the above — the parts I'm least sure on are (a) whether the team wants HoverCard to swallow tap on wrapped links or defer to them, and (b) whether to make the touch behavior opt-in via prop or default-on.

    Small context that might be relevant: I just filed a broader contrast audit across the design system in #4652, so I have a fresh read on the tokens and primitives. Happy to cross-reference that with whatever ends up here.

  6. cixzhang commented on Aug 21, 2026

    @cixzhang
    ContributorAuthor

    Resolved by #5248 (mobile access for HoverCard/Tooltip).

  7. added this to the 0.4.6 milestone on Aug 21, 2026
  8. gonzoblasco commented on Aug 21, 2026

    @gonzoblasco
    Contributor

    Following up now that #5248 landed - glad to see the direction it took, since it matches the accessibility contract I sketched in my comment back in July (issuecomment-4991984976).

    The pieces that line up with the "toggletip, not long-press" proposal:

    • aria-describedby exposed on the trigger so screen reader users get the content announced on focus, with no gesture required
    • Escape dismissal (WCAG 1.4.13 - dismissible), plus tap-outside and second-tap close
    • isActionTrigger keeping a wrapped button/link/form control's own tap intact instead of swallowing it - the interactive-check guard I flagged as the trap with naive tap-to-toggle
    • No long-press, which was the whole point of that comment: it collides with native text selection, is invisible to sighted users, and is hostile to motor-impaired users.

    For the record, the one thing I proposed that does not appear here is an explicit visible close affordance inside the card (I suggested it alongside Escape for 1.4.13). Escape + outside-tap cover dismissal, so it is not a compliance gap - just flagging that a visible dismiss button is the more discoverable option for touch users who may not know the tap-outside gesture.

    Nice implementation and test coverage - the pointer-type-per-interaction decision (stylus as hover) is a smart touch. Glad the touch path is finally reachable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    componentdesignenhancementneeds-scopingneeds:design-review

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions