Skip to content

Tooltip

A plain label on hover or focus, or a rich tooltip with a subhead and an action.

import { Tooltip, RichTooltip, TooltipTrigger, RichTooltipTrigger } from '@windmorph/react';

Keyboard

Tooltip keyboard
KeyAction
TabFocusing the trigger shows its tooltip; moving focus away hides it at once.Plain and transient rich tooltips
EscapeHides the tooltip.Plain and transient rich tooltips
Enter or SpaceOpens or closes the rich tooltip. Focus stays on the trigger.On a persistent trigger
TabFrom the trigger, moves into the open tooltip, to its first link or button. From its last control, moves on to whatever follows the trigger on the page, which closes it.Persistent rich tooltip
Shift + TabMoves back through the tooltip's controls to its trigger. From whatever follows the trigger, moves into the tooltip, at its last control.Persistent rich tooltip
EscapeCloses the tooltip, from its trigger or from inside it, and puts focus back on the trigger.Persistent rich tooltip

A persistent rich tooltip is portalled to the end of the document, but its controls come straight after its trigger in the Tab order, as M3's focus order asks.

Screen reader

Role
tooltip for a plain tooltip and a transient rich tooltip. A persistent rich tooltip is a non-modal dialog (no aria-modal), so screen readers don't announce a modal.
Accessible name
A plain or transient tooltip describes its trigger (aria-describedby), so it is read after the trigger's own name. A persistent rich tooltip is named by its title, or by aria-label when it has none.
States announced
A persistent trigger announces that it opens a dialog (aria-haspopup="dialog"), whether it is open (aria-expanded), and points at the open tooltip (aria-controls).
  • The caret is decorative and hidden from assistive tech (aria-hidden).
  • Tooltips sit above every other layer: a modal open underneath (a dialog or sheet) neither hides them from assistive tech nor pulls focus out of them.

Focus

  • A plain or transient tooltip never takes focus; it shows while its trigger is hovered or keyboard-focused, or after a touch long press.
  • A tooltip shown by focus does not hide on a timer: it stays until focus leaves, the pointer leaves, or Escape, as WCAG 1.4.13 asks. It also stays while the pointer is over it, and for 1.5 seconds (closeDelay) after the pointer leaves or a touch lifts.
  • A transient rich tooltip stays open while focus is inside it, and closes when focus leaves.
  • Opening a persistent rich tooltip leaves focus on the trigger, and the tooltip never traps focus. It closes when the trigger is pressed again, on Escape, or on a press anywhere outside it; it stays when the pointer leaves.

Touch target

None. A tooltip isn't a target itself: on touch it opens from a long press on its trigger. Put actions in a rich tooltip as buttons, which bring their own touch targets.

Motion

Under reduced motion the tooltip only fades in and out: it is not revealed from the side of its anchor.

What you need to do

  • Don't use a tooltip as the only name of a control: give an icon-only button its own aria-label; the tooltip adds a description.
  • Keep plain tooltips short and free of links or buttons. When a tooltip holds actions keyboard users must reach, use a RichTooltipTrigger with persistent.
  • Give a persistent rich tooltip a title, or an aria-label when it has no subhead.
  • Don't put information only in a tooltip that people need to complete a task, since touch users have to long-press to see it.