Tooltip
Tooltip shows the name of a control when the pointer rests on it or the control receives keyboard focus.
<TooltipProvider> <Tooltip> <TooltipTrigger render={<Button aria-label="Undo" />} /> <TooltipContent>Undo</TooltipContent> </Tooltip></TooltipProvider>A Tooltip shows a short label when the pointer rests on a control or the control receives keyboard focus. Use it to name an icon-only button and to show its keyboard shortcut.
A tooltip should only repeat what the control already says. Touch screens have no hover, so tooltips never open there, and screen readers don't announce them. Give the control an aria-label with the same name, so everyone gets the information whether or not they see the tooltip.
When the panel needs more than one line of text, a form or a link, use a Popover. For a hint that touch users also need, use a FieldDescription or a Notice. TooltipContent accepts only a string, so write a shortcut as text, for example Undo ⌘Z.
A tooltip uses inverted colours, dark on a light page and light on a dark page. It opens above the control by default. Use side and align on TooltipContent to change that, and the tooltip moves to the opposite side when there isn't enough room.
Put one TooltipProvider near the root of your app. It sets the delay for every tooltip inside it and groups them, so once one tooltip has opened, the next ones open straight away as the pointer moves along a row of buttons. Base UI's Tooltip provides the behaviour, and the part names follow shadcn/ui.
- Popover when the panel holds content or controls people need.
Topics
Every symbol this component exports, grouped by the job it does. Each one carries the props it declares; each one has an anchor of its own.
Naming a control
Tooltip
Tooltip shows the name of a control when the pointer rests on it or the control receives keyboard focus.
| Prop | Type | What it does |
|---|---|---|
children? | React.ReactNode | A TooltipTrigger and a TooltipContent, in that order. |
defaultOpen? | boolean | Whether the tooltip starts open, when you don't control it. |
onOpenChange? | (open: boolean, details: TooltipOpenChangeDetails) => void | Called when the tooltip opens or closes. |
open? | boolean | Whether the tooltip is open. |
It declares no props of its own. What it takes arrives from a shared type or from the primitive it is built on.
TooltipContent
The text of the tooltip: one short line with the control's name, followed by its shortcut if it has one
| Prop | Type | What it does |
|---|---|---|
align? | "start" | "center" | "end" | How the tooltip lines up with the trigger along that side. |
children? | string | The text of the tooltip. |
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
side? | "top" | "right" | "bottom" | "left" | The side of the trigger to show the tooltip on. |
sideOffset? | number | The gap between the trigger and the tooltip, in pixels. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
It also takes every prop of a <div>.
- Content that is not a string — A tooltip inverts the colours of its panel, and other components placed inside it wouldn't invert with it. Write a shortcut into the text, or use a Popover for richer content.
- A size — A tooltip has one small size everywhere, because it shows one short line of text whatever the size of the control it names.
toneandemphasis— A tooltip only repeats a control's name, so a colour or a level of prominence would have nothing to say.- A delay you set per tooltip — Tooltips that open at different speeds make an app feel inconsistent. Set the delay once, on the
TooltipProvidernear the root of your app. - Support for touch screens — Phones have no hover, so tooltips never open there. Put any hint that touch users need in a
FieldDescriptionor aNotice. - A material — The inverted colours already give a tooltip the strongest contrast available, and glass would add a second edge around a small panel.
- An arrow — The tooltip opens right next to its control, so its position already shows which control it names.