On this page

InstallationUsageAnatomyVariantsSide and alignmentAlong a rowDelayLong textWith a shortcutBuilt on itWhere it is usedAccessibilityAPI ReferenceTooltipTooltipTriggerTooltipContentTooltipProviderAs a propRulesWritten downOpen questionsWhat others adviseWhat others expose

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.

1<Button emphasis="ghost" iconStart={BookOpen} tooltip="Documentation" />

Installation

text
import { Tooltip, TooltipContent, TooltipTrigger } from "@dome-systems/ds-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.

1<Tooltip>2  <TooltipTrigger3    render={<Button emphasis="ghost" iconStart={Copy} aria-label="Copy ID" />}4  />5  <TooltipContent>Copy ID</TooltipContent>6</Tooltip>

Anatomy

Documentation 1234
  1. 1 — Box. Near-black at 90% with 6px corners, with no arrow and no border.
  2. 2 — Text. 12px, medium weight.
  3. 3 — Gap. 6px off the trigger, on the side with room: above by default.
  4. 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.

1<Button size="sm" tooltip="Opens the agent's page">Default</Button>2<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.

1<Button size="sm" tooltip={{ children: "Top", side: "top" }}>Top</Button>2<Button size="sm" tooltip={{ children: "Right", side: "right" }}>Right</Button>3<Button size="sm" tooltip={{ children: "Bottom", side: "bottom" }}>Bottom</Button>4<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.

1<Button emphasis="ghost" iconStart={Plus} tooltip="Add agent" />2<Button emphasis="ghost" iconStart={Check} tooltip="Approve" />3<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.

1<Button size="sm" tooltip="At once">No delay</Button>2<Button size="sm" tooltip={{ children: "After 400ms", delay: 400 }}>400ms</Button>

Long text

One run of text (a label, a sentence, a paragraph) stays on one line while it fits in 280px, then wraps into lines of even length, in a box as wide as its longest line. There is no prop for this. On a narrow window the box is at most the window's width less 16px.

1<Button size="sm" tooltip="Disable">Short</Button>2<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.

1<Button emphasis="ghost"2  iconStart={Copy}3  aria-label="Copy ID"4  tooltip={{ children: <span className="flex items-center gap-1.5">Copy ID <Kbd>⌘C</Kbd></span> }}5/>

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.

agent-with-a-very-long-name1.9M
1<span className="flex items-center gap-5 text-body-2 text-neutral-fg">2  <Truncate maxWidth={120}>agent-with-a-very-long-name</Truncate>3  <Hint tooltip="1,948,935 tokens">1.9M</Hint>4  <IconTooltip tooltip="Counted over the last 24 hours." label="About this number" />5</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

customer-success-agent-production

A text that was cut

Truncate, in 13 product files: the names and ids that tables cut.

ds/components/truncate.tsx

Token lifetime

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

1.9M

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.

PropTypeDefaultDescription
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.
glidebooleantrue (false for mini)Shown right after another tooltip, slide and resize from it instead of appearing.

TooltipTrigger

PropTypeDefaultDescription
renderReactElement—The element you point at. The trigger adds nothing around it.
delaynumberthe provider's (0)How long the pointer rests before the tooltip shows, in ms.
closeDelaynumber0How long it stays after the pointer leaves, in ms.
closeOnClickbooleantrueClose when the trigger is pressed.

TooltipContent

PropTypeDefaultDescription
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.
sideOffsetnumber6 (4 for mini)The gap to the trigger, in px.
alignOffsetnumber0A nudge along the side, in px.
childrenReactNode—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.

PropTypeDefaultDescription
delaynumber0The wait for every tooltip inside, in ms, unless a trigger sets its own.
timeoutnumber300How 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.

text
<Button tooltip="Delete" />
<Button tooltip={{ children: "Delete", side: "bottom", delay: 400 }} />

Rules

Written down

One line up to 280px, then lines of even length

Pass the text and let the Tooltip size itself. 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.

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?

Open
Ours

It 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.

Other systems

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?

Open
Ours

The README counts links and code as part of a tooltip's text. A pointer can reach a link there; a keyboard cannot.

Other systems

Atlassian, Polaris and Primer all say text only, with nothing to press.

What explains a disabled button?

Open
Ours

A 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.

Other systems

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?

Open
Ours

It fades in, and glides from the last tooltip, whatever the system setting says. Nothing written covers it.

Other systems

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 adviseWho
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 exposeOursWhy
A shortcut as a prop of the tooltip (Atlassian, Primer)Already thereA Kbd inside the content. Its colors are wrong in dark today.
Placing it by the pointer (Atlassian, Base UI)Already thereThe anchor prop.
A wait before it shows (Primer, Polaris, Atlassian)Already theredelay, 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 thereTruncate, for cut text; the root's disabled for anything else.
A dotted line under text that has a tooltip (Polaris)Already thereHint.
Stay open when pressed (Base UI, Polaris, Atlassian)AskcloseOnClick is on TooltipTrigger, not in a Button's tooltip prop.
An arrow pointing at the trigger (Base UI, shadcn)Not neededWritten: the README and the source say no arrow.
Width, padding and corner props (Polaris)AskThe width is one token; padding and corners have no prop.
One tooltip shared by many triggers, with its content animated (Base UI)AskThe glide moves one tooltip's box to the next.