Tooltip
A tooltip is one line of text that appears next to a control when the pointer rests on it or keyboard focus arrives, usually to name an icon button and show its shortcut.
When to use it
Give a tooltip to an icon button, since the icon alone may not say what it does, and to a control that has a keyboard shortcut. A truncated value can show its full text in one, and an unavailable control can say what would make it available.
Touch screens have no hover, so tooltips do not appear there. Keep what people need on the page or in a popover.
Sunita Rai
Care assistant, Pokhara
Anatomy
A tooltip is plain text on frosted glass. When the control has a shortcut, a keycap follows the text.
- Text
- 12 px on an 18 px line, regular weight
- --text
- Padding
- 4 px above and below, 8 px at the sides
- --space-1, --space-2
- Height
- 26 px
- Corner radius
- 8 px
- --radius-lg
- Surface
- translucent glass under a strong blur, with a soft shadow. Solid where the blur cannot render
- Gap to the control
- 8 px
- --space-2
- Distance from the window edge
- at least 8 px
- --space-2
- Keycap
- 11 px, weight 500, 6 px corners, on the control fill with a 1 px edge
- --surface-control, --border, --text-label, --radius-md
- Length
- at most 60 characters
Showing and hiding
The tooltip stays while the pointer is on the control or on the tooltip itself, so people can move onto it to read it. It does not time out, and only one shows at a time.
It opens below the control, centered, and moves above it at the bottom of the window. Near the sides it moves inward.
- Pointer rests on the control
- shows after 500 ms
- Keyboard focus arrives
- shows at once
- Moving to another control while one shows
- the next shows at once
- Fade in and out
- 150 ms
- --duration-fast
- Pointer leaves the control and the tooltip
- hides
- Focus leaves, or Escape
- hides, focus stays where it was
- A press on the control
- hides
Content
Name the action in a short phrase, in sentence case, with no full stop. Leave out words people can already see on the control. For an unavailable control, say what would make it available.
Permitted
Download CV
Names the action of an icon button.
Select a candidate first
Says why the control is unavailable.
Not permitted
Click here to download the CV of this candidate.
It explains the obvious and ends with a full stop.
A link or a button inside a tooltip
A tooltip holds text only. Use a popover.
Accessibility
The tooltip has role tooltip and an id. When it adds to the control's name, the control points to it with aria-describedby. When it repeats the aria-label of an icon button, the tooltip is hidden from screen readers, so the name is heard once.
A control with a shortcut states it in aria-keyshortcuts. An unavailable control that explains itself uses aria-disabled, so it still takes focus and shows its tooltip. Remove the title attribute from any control that has a tooltip.