Tooltip
A short hint on hover or focus.
Left out of Accessible first Icons never stand alone here, so no control needs a hover hint. Touch screens never hover, and optional help sits in a section a person can open. Use instead: Collapsible, Label
See it live
npm run storybookWhen to use it
- Use it when: A brief name or hint for a control that already has an accessible name.
- Not when: The only place values or important words live, or touch screens, where hover never happens.
Instead:
- Popover: Opens on click and works on touch.
- Hover card: A richer preview.
How Accessible first uses it
Words
- Use common words. Explain any term you must use.
- One idea per sentence. Put the action first.
- Never blame the person.
- Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.
The labels components use, from the voice tokens:
content.action.commit: Continuecontent.action.cancel: Go backcontent.action.destroy: Deletecontent.action.retry: Try againcontent.action.empty-action: Start a new application
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Escape hides it. | undefined |
Test before you ship:
- It describes its trigger and also shows on keyboard focus. undefined
Use it in code
npx open-ds add tooltip
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Tooltip reads 7 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Tooltip's tokens to change Tooltip alone.
Accessible first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Tooltip | ||
| Fill Changes with theme | component.tooltip.backgroundcolor.surface.inversevar(--tooltip-background) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Text Changes with theme | component.tooltip.labelcolor.text.inversevar(--tooltip-label) | Lightgray.light.0:#FFFFFFDarkgray.light.900:#141414 |
| Content | ||
| Corner | component.tooltip.content.radiusradius.badgevar(--tooltip-content-radius) | radius.4:0.25rem |
| Padding, left and right | component.tooltip.content.padding-xspace.gap.defaultvar(--tooltip-content-padding-x) | space.16:1rem |
| Padding, top and bottom | component.tooltip.content.padding-ycomponent-spacing-map.x1var(--tooltip-content-padding-y) | space.4:0.25rem |
| Text size | component.tooltip.content.font-sizetype.caption.font-sizevar(--tooltip-content-font-size) | font.size.16:1rem |
| Font family | component.tooltip.content.font-familytype.caption.font-familyvar(--tooltip-content-font-family) | font.family.atkinson-hyperlegible:"Atkinson Hyperlegible", Verdana, sans-serif |