Tooltip
A short label that appears on hover or focus, mostly for icon-only controls.
When to use
- Name an icon-only button:
Copy API keyon a copy icon. - Show the keyboard shortcut for a control.
When not to use
- Information users need to finish the task: put it on the page, or in a Field description.
- Links, buttons, or several lines of content: use Popover.
- A preview of a linked person or record: use Hover Card.
Install
npx shadcn@latest add @clinia/tooltipClinia rules
- The tooltip is
text-xson an invertedbg-foregroundsurface, so its text keeps full contrast in both themes. TooltipProvidersetsdelayto 0: the tooltip opens as soon as the pointer rests. Mount the provider once, at the app root.- Copy is a short phrase in sentence case with no final period. It matches the control's accessible name.
- A
Kbdinside the tooltip shows a shortcut. The tooltip adjusts its padding to fit it.
Do and don't
Copy API key
Deletes all 1,204 records. This can't be undone.
Accessibility
Built in
- Opens on hover and on keyboard focus. Escape closes it.
Your responsibility
- Give the trigger an
aria-labelthat matches the tooltip text. The tooltip is a visual label only, and screen readers don't rely on it. - Touch screens can't hover. Never make a tooltip the only place a name, a warning, or an instruction appears.
How to test
- Press Tab to the trigger: the tooltip opens.
- Press Escape: it closes, and focus stays on the trigger.
- With a screen reader, the trigger is announced by its
aria-label, the same words as the tooltip. - On a phone, check that the control still makes sense with no tooltip at all.
API
Every prop comes from Base UI Tooltip.
Related