Tooltip

Names a control on hover or focus.

Side

  • topdefault

  • bottom

  • left

  • right

Content

  • labeldefault

  • label + shortcut

  • drawn

Provider

  • toolbar

Usage

When to use it
Use
An icon button needs its name shown: replay, pause, drop.
Use
A control has a keyboard shortcut worth teaching.
Not for
The text explains something the person needs to act. Use Popover.
Not for
The text is a sentence or holds a link. Use Popover.

Rules

6 rules
Must
Give a tooltip a short label in sentence case, a verb and its object, and at most a shortcut. Because the label is the control's name in mono capitals, and links or sentences inside cannot be reached or read.
Never
Put anything a person needs in a tooltip alone. Because it never opens on touch and a screen reader may never meet it.
Should
Leave aria-label off an icon trigger with a tooltip; the tooltip's text names it. Because one string for the eye and the screen reader cannot drift apart.
Should
Wrap a toolbar's tooltips in one TooltipProvider. Because after the first opens, the next opens at once as the pointer moves along the row.
Never
Restyle the tooltip into a solid ink or yellow chip. Because a solid block on a white page pulls the eye like the slab does, and every Sodium overlay is the panel with a rule edge.
Must
Give a disabled control's tooltip a wrapper trigger that can take focus, and say why it is disabled on the page too. Because a disabled button takes no pointer or focus events, so its own tooltip never opens.

Accessibility

3 checks
The trigger is described by the tooltip; a nameless trigger takes its text as aria-label.
Keyboard focus opens it at once, and Escape closes it.
The label is text-1 on the panel at 17.6:1 and 14.9:1; the edge is --line, the rule colour.

Keyboard

2 keys
Tab
Focusing the trigger opens the tooltip at once.
Escape
Closes it; focus stays on the trigger.

Edge cases

4 edge cases
Touch
It never opens; the control's name is still read from the label.
Long label
Wraps at 256px; past that, it belongs in a Popover.
Near a viewport edge
It flips to the other side.
Reduced motion
It cuts in and out.

API

5 props
TooltipContent children
string
TooltipContent shortcut
string
TooltipContent side, align
Base UI default 'top', 'center'
TooltipProvider delay
number default 500
TooltipChip
component

Tokens

10 tokens
--panel
#fafaf7
--line
#e2dfd5
--tooltip-max
256px
--type-label-sm
400 12px/16px var(--font-mono)
--type-micro
400 11px/14px var(--font-mono)
--text-1
#161512
--overlay-shift
4px
--z-overlay
50
--dur-overlay
160ms
--dur-state
120ms

Install

For your coding agent

GitHub

Please star me pookie

198

A new design system every week

Leave your email before you copy the prompt.