Skip to content

Tooltip ​

A hint on hover and on keyboard focus. Every hint in an app is one of these, never a title attribute.

tsx
import { Tooltip } from '@adecore/ui';
tsx
import { Button, Icon, Tooltip, shortcut } from '@adecore/ui';
import { History, Info, Search } from 'lucide-react';

const SEARCH = shortcut('Mod+K');

export default function TooltipDemo() {
    return (
        <div className="flex items-center gap-3">
            <Tooltip label="Search everything" kbd={SEARCH}>
                <Button variant="secondary">
                    <Icon icon={Search} size={14} />
                    Search
                </Button>
            </Tooltip>
            <Tooltip label="Reload" kbd="Shift skips the cache" side="bottom">
                <Button variant="secondary">Reload</Button>
            </Tooltip>
            <Tooltip label="About this view" name side="right">
                <button type="button" className="focus-ring grid size-6 place-items-center rounded-md text-text-muted">
                    <Icon icon={Info} size={14} />
                </button>
            </Tooltip>
            <Tooltip label="Tightened the intro to four seconds, moved the title card after the first cut and brought the music down under the voice-over.">
                <Button variant="secondary">
                    <Icon icon={History} size={14} />
                    Version 3
                </Button>
            </Tooltip>
        </div>
    );
}

The child is the trigger and must take a ref. Base UI merges the tooltip's props into it.

kbd prints a shortcut after the label, or a short phrase such as "Shift skips the cache". A real shortcut also registers with ShortcutHints.

name makes the label the trigger's accessible name too, as an icon-only button needs. IconButton does this with its label.

A label wraps past 288 pixels.

Content without a DOM trigger ​

For a link inside a terminal or a canvas, pass open, onOpenChange and an anchor with getBoundingClientRect() in viewport coordinates, and leave out children. The popup then ignores the pointer. The host decides when a link is hovered.

tsx
<Tooltip
    open={hovered !== null}
    onOpenChange={(open) => { if (!open) { setHovered(null); } }}
    anchor={hovered ? { getBoundingClientRect: () => new DOMRect(hovered.x, hovered.y, 0, 0) } : null}
    label="Cmd+click to open"
/>

Delay ​

Tooltips share one delay through UIProvider: 150 milliseconds to open, none to close. After the first tooltip, the next button's opens at once and the tooltip slides over.

Props ​

PropTypeDefault
labelReactNodeRequired.
childrenReactElementThe trigger. Omit for a controlled virtual anchor.
openbooleanControls visibility.
onOpenChange(open: boolean) => voidReceives dismissals and trigger changes.
anchorTooltipPositioner.Props['anchor']An element, ref or virtual rectangle.
kbdShortcut | stringPrinted after the label.
sideTooltipSide'top''top' | 'bottom' | 'left' | 'right'
sideOffsetnumber6
namebooleanfalseMakes a string label the trigger's aria-label.
disabledbooleanfalseKeeps the hint closed.

TooltipProps and TooltipSide are exported types.

Licenses and third-party notices are listed in each package.