Tooltip
A few words that appear beside something under the pointer or on keyboard focus: an icon button's name, a shortcut, the rest of a text that was cut.
<Button emphasis="ghost" iconStart={BookOpen} tooltip="Documentation" />Installation
import { Tooltip, TooltipContent, TooltipTrigger } from "@catalog-dashboard/components";Usage
Most of the time you write none of the parts: a Button, an IconTooltip, a Truncate and a Hint take the tooltip themselves. On a Button with no label, a tooltip given as a string is also its name for a screen reader.
For anything else, the three parts: Tooltip holds the state, TooltipTrigger is what you point at (give it your element with render), TooltipContent is what shows.
<Tooltip> <TooltipTrigger render={<Button emphasis="ghost" iconStart={Copy} aria-label="Copy ID" />} /> <TooltipContent>Copy ID</TooltipContent></Tooltip>Anatomy
- 1 · Box. Near-black at 90% with 6px corners, with no arrow and no border.
- 2 · Text. 12px, medium weight.
- 3 · Gap. 6px off the trigger, on the side with room: above by default.
- 4 · Trigger. What you point at or tab to. It keeps its own name.
Variants
default is the dark box, the same in light and dark, beside its trigger. mini looks like the browser's own title tooltip, just below the pointer: light in light, dark in dark.
<Button size="sm" tooltip="Opens the agent's page">Default</Button><Button size="sm" tooltip={{ children: "Opens the agent's page", variant: "mini" }}>Mini</Button>Side and alignment
Above its trigger and centered by default. side and align move it; it flips when there is no room.
<Button size="sm" tooltip={{ children: "Top", side: "top" }}>Top</Button><Button size="sm" tooltip={{ children: "Right", side: "right" }}>Right</Button><Button size="sm" tooltip={{ children: "Bottom", side: "bottom" }}>Bottom</Button><Button size="sm" tooltip={{ children: "Left", side: "left" }}>Left</Button>Along a row
A TooltipProvider gives the tooltips inside it one clock. One opened within 300ms of another does not appear: it slides and resizes from the last, so moving along a toolbar reads as one tooltip changing its words. glide turns it off.
<Button emphasis="ghost" iconStart={Plus} tooltip="Add agent" /><Button emphasis="ghost" iconStart={Check} tooltip="Approve" /><Button emphasis="ghost" iconStart={ArrowRight} tooltip="Open in a new tab" />Delay
A tooltip shows at once. delay, in milliseconds, makes it wait: on a trigger, on a provider, or in the prop.
<Button size="sm" tooltip="At once">No delay</Button><Button size="sm" tooltip={{ children: "After 400ms", delay: 400 }}>400ms</Button>Long text
A one-liner or a paragraph. One run of text (a label, a sentence, a paragraph) keeps its own width while it fits on one line in 280px; past that it is a paragraph 280px wide, its lines filled left to right. There is no prop for this. On a narrow window the box is at most the window's width less 16px.
<Button size="sm" tooltip="Disable">Short</Button><Button size="sm" tooltip="Stops this agent from calling tools until you turn it back on. Its keys stay valid.">Long</Button>With a shortcut
A Kbd after the words. Content with boxes of its own, like this, keeps its layout, up to 320px. In light the key takes the tooltip's inverted colors. In dark its text is close to the box's color and does not read: a fault in the Kbd, not fixed here.
<Button emphasis="ghost" iconStart={Copy} aria-label="Copy ID" tooltip={{ children: <span className="flex items-center gap-1.5">Copy ID <Kbd>⌘C</Kbd></span> }}/>Built on it
Three pieces carry a tooltip so you do not wire one. Truncate shows all of a text that is cut, and only while it is cut. Hint puts a dotted line under text that has more to say. IconTooltip is the small info icon beside a label.
<span className="flex items-center gap-5 text-body-2 text-neutral-fg"> <Truncate maxWidth={120}>agent-with-a-very-long-name</Truncate> <Hint tooltip="1,948,935 tokens">1.9M</Hint> <IconTooltip tooltip="Counted over the last 24 hours." label="About this number" /></span>Where it is used
The product is midway. 48 files still import the older tooltip (components/ui/tooltip.tsx), and the dashboard's layout mounts that one's provider. A ds Tooltip there brings its own, so nothing glides in the product yet; it does in this catalog. Besides the uses below, a few screens wire the three parts themselves (the status tile, the user menu).
An icon button's name
A ds Button with no label is named by its tooltip's text. One ds Button in the product carries a tooltip so far, the context switcher's Back. The dashboard's own Button has no tooltip prop.
ds/components/button.tsx
A text that was cut
Truncate, in 13 product files: the names and ids that tables cut.
ds/components/truncate.tsx
The info icon beside a label
IconTooltip, the dashboard's help icon: on a Field's label, beside a section's title, in a tab.
ds/components/icon-tooltip.tsx
A value with more to say
Hint: a dotted line under a shortened number, its full form in the tooltip. The Table draws it for a short count or cost, as on the Agents list.
ds/components/hint.tsx, ds/components/table/cell.tsx
A status with no room for its word
The ds Table's folded status dot, and this catalog's doc mark: a dot named by its tooltip. Catalog only: no screen uses the ds Table yet.
ds/components/table/cell.tsx
The sidebar, folded to icons
Each row's label is its tooltip, to the right of the rail. This is the older tooltip, not this one.
ds/components/sidebar.tsx
Accessibility
A tooltip opens when the pointer rests on its trigger and when the trigger takes keyboard focus. Escape closes it and leaves focus where it was. It stays open while the pointer is on the trigger or on the tooltip itself, and closes when the pointer or the focus leaves. It does not open on a touch screen.
The tooltip's text is not read by a screen reader. It is not tied to its trigger: there is no role="tooltip" and no aria-describedby. The trigger carries its own name. A Button with no label takes a string tooltip as its aria-label; a tooltip given as elements names nothing, so give that button an aria-label. An IconTooltip with a label is named by the label and takes a tab stop; without one it is reached by a pointer only.
A plain disabled button takes no pointer, so its tooltip never opens. The text is near-white on a near-black box in both themes. The fade and the glide play whatever the reduced-motion setting says.
API Reference
Tooltip
Besides these, every prop of Base UI's Tooltip root: open, defaultOpen and onOpenChange to hold it open yourself, disabled, disableHoverablePopup.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "mini" | "default" | The dark box, or the look of the browser's own title tooltip. |
anchor | "trigger" | "pointer" | "trigger" ("pointer" for mini) | Beside the trigger, or just below the pointer where the browser puts a title. Opened from the keyboard it takes the trigger. |
glide | boolean | true (false for mini) | Shown right after another tooltip, slide and resize from it instead of appearing. |
TooltipTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
render | ReactElement | — | The element you point at. The trigger adds nothing around it. |
delay | number | the provider's (0) | How long the pointer rests before the tooltip shows, in ms. |
closeDelay | number | 0 | How long it stays after the pointer leaves, in ms. |
closeOnClick | boolean | true | Close when the trigger is pressed. |
TooltipContent
| Prop | Type | Default | Description |
|---|---|---|---|
side | "top" | "right" | "bottom" | "left" | "inline-start" | "inline-end" | "top" | Which side of the trigger. It flips when there is no room. |
align | "start" | "center" | "end" | "center" | Along that side. |
sideOffset | number | 6 (4 for mini) | The gap to the trigger, in px. |
alignOffset | number | 0 | A nudge along the side, in px. |
children | ReactNode | — | What it says. One run of text is fitted by the Tooltip; content with boxes of its own keeps its layout. |
TooltipProvider
The shared clock behind the glide. This catalog has one around it; the dashboard does not mount it yet. A Tooltip outside any provider brings its own.
| Prop | Type | Default | Description |
|---|---|---|---|
delay | number | 0 | The wait for every tooltip inside, in ms, unless a trigger sets its own. |
timeout | number | 300 | How long after one tooltip closes the next still glides from it, in ms. |
As a prop
A Button's and an IconTooltip's tooltip, and a tab's iconTooltip, take a string, or an object of TooltipContent's props (the text as children, side, align…) with the Tooltip's variant, anchor and glide, and delay. A tab's iconOnly takes the same object without the text.
<Button tooltip="Delete" />
<Button tooltip={{ children: "Delete", side: "bottom", delay: 400 }} />Rules
Written down
A one-liner, or a 280px paragraph
Pass the text and let the Tooltip size itself: its own width on one line, or a paragraph 280px wide once it wraps, never two even halves. The rule covers a label, a sentence or a paragraph, its links and code included. Content with boxes of its own keeps its layout and a 320px limit, and its text wraps the same way.
From ds/README.md (Tooltip) and ds/components/tooltip.tsx.
It shows at once
The delay is 0 by default. A trigger or a provider can make it wait.
From ds/components/tooltip.tsx and ds/README.md (Tooltip).
Cut text waits 200ms
Do: give a tooltip that shows cut or shortened text a 200ms wait.
Don't: delay a tooltip on an icon, an icon button, the (i) or a status reason.
From ds/components/truncate.tsx (CUT_TEXT_TOOLTIP_DELAY).
A button with no label needs a name
A string tooltip gives it one. A tooltip given as elements does not, so that button takes an aria-label.
From ds/components/button.tsx.
Every help icon is the Icon tooltip
A span, not a button, so it sits inside a tab or a button, on hover only. With a label it stands on its own after a field's or a section's title, reached with the keyboard and named by the label.
From ds/README.md (Icon tooltip).
Cut text never has two tooltips
Truncate sets no native title, and its tooltip shows only while the text really overflows. The whole text stays in the page for a screen reader.
From ds/components/truncate.tsx and ds/README.md (Truncate).
In a table, only where something is cut or has no name
Cut text, an icon-only header, a column's help, the folded status dot and an icon mark. Not on a relative time, a whole number or a date. The dotted hint goes only under a shortened number, and the help cursor is never used.
From the Table's rules (T8).
Open questions
Should a screen reader hear the tooltip?
OpenIt does not today. Only a name gets through: an icon button's string tooltip, an Icon tooltip's label. What an Icon tooltip or a Hint explains is never read. Nothing written chooses.
Primer makes every tooltip either the trigger's name or its description. Atlassian keeps a hidden copy of the text for screen readers. Polaris ties the text to its trigger as a description. Base UI, which ours is built on, says the trigger must have its own label.
May a tooltip hold a link?
OpenThe README counts links and code as part of a tooltip's text. A pointer can reach a link there; a keyboard cannot.
Atlassian, Polaris and Primer all say text only, with nothing to press.
What explains a disabled button?
OpenA plain disabled button opens no tooltip. One that keeps its focus (focusableWhenDisabled, which a loading Button sets) can still open one. Nothing written says which a screen should use.
Atlassian says to explain it on the page, not in a tooltip. Primer allows no tooltip on a disabled element and points to aria-disabled instead. shadcn wraps the disabled button so a tooltip can still open.
Should it stand still under reduced motion?
OpenIt fades in, and glides from the last tooltip, whatever the system setting says. Nothing written covers it.
None of the tooltip pages we read says.
What others advise
None of this is decided for us. It is what Atlassian, Polaris, Primer and Base UI tell their own teams, listed so you can pick. The last two go against what we have written: our Icon tooltip is a hover-only span, and a table's status dot carries a tooltip.
| Others advise | Who |
|---|---|
| Nothing a person needs to finish the task goes in a tooltip. | Atlassian, Polaris, Primer, Base UI |
| An icon-only button gets a tooltip that says its name. | Atlassian, Polaris, Primer |
| A screen that needs many tooltips needs clearer design and wording first. | Polaris |
| Keep the text concise (all three), in sentence case (Polaris). | Atlassian, Polaris, Primer |
| Never use the native title attribute. | Atlassian |
| A tooltip goes only on an interactive element (both); one that does something when clicked (Primer). | Primer, Atlassian |
| An info icon's popup is a popover that opens on hover, not a tooltip. | Base UI |
What others expose
What shadcn, Base UI, Atlassian, Polaris and Primer offer for tooltips, and where ours stands on each.
| They expose | Ours | Why |
|---|---|---|
| A shortcut as a prop of the tooltip (Atlassian, Primer) | Already there | A Kbd inside the content. Its colors are wrong in dark today. |
| Placing it by the pointer (Atlassian, Base UI) | Already there | The anchor prop. |
| A wait before it shows (Primer, Polaris, Atlassian) | Already there | delay, in ms. Ours and Polaris show at once by default; Primer waits 50ms, Atlassian 300ms. |
| Show only when a test passes, such as text being cut (Atlassian) | Already there | Truncate, for cut text; the root's disabled for anything else. |
| A dotted line under text that has a tooltip (Polaris) | Already there | Hint. |
| Stay open when pressed (Base UI, Polaris, Atlassian) | Ask | closeOnClick is on TooltipTrigger, not in a Button's tooltip prop. |
| An arrow pointing at the trigger (Base UI, shadcn) | Not needed | Written: the README and the source say no arrow. |
| Width, padding and corner props (Polaris) | Ask | The width is one token; padding and corners have no prop. |
| One tooltip shared by many triggers, with its content animated (Base UI) | Ask | The glide moves one tooltip's box to the next. |