Names an icon-only control and shows its shortcut.
import { Button, Tooltip } from "@usememos/ui";
import { Archive } from "lucide-react";
<Tooltip.Provider>
<Tooltip.Root>
<Tooltip.Trigger render={<Button variant="ghost" icon={<Archive />} aria-label="Archive" />} />
<Tooltip.Popup shortcut="⌘ E">Archive</Tooltip.Popup>
</Tooltip.Root>
</Tooltip.Provider>| Part | Base UI part | Renders |
|---|---|---|
Tooltip.Provider |
Tooltip.Provider |
Nothing. Shares the hover delay, so the next tooltip in a toolbar opens at once |
Tooltip.Root |
Tooltip.Root |
Nothing. Groups a trigger and its popup |
Tooltip.Trigger |
Tooltip.Trigger |
The control, usually a Button through render |
Tooltip.Popup |
Tooltip.Portal, Positioner, Popup |
The label, a <div> portaled to the body |
interface Tooltip.TriggerProps extends BaseTooltip.Trigger.Props {
delay?: number; // hover time before opening, ms; default 400
}
interface Tooltip.PopupProps extends BaseTooltip.Popup.Props {
shortcut?: React.ReactNode; // after the label, at 65% opacity
side?: Side; align?: Align; // Positioner props; default side "top"
container?: HTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | null; // portal target
}Base UI's props pass through: open, defaultOpen, onOpenChange, disabled on the root; closeOnClick on the trigger; delay, closeDelay, timeout on the provider.
- Give every icon-only Button and Toggle a tooltip with the same text as its
aria-label. Two or three words. - Dialog, Drawer and Toast include the Tooltip on their built-in Close; it uses
closeLabeland the popup'scontainer. Combobox includes one on its chevron, usingtriggerLabel. These tooltips stay inside a shadow root when their trigger is mounted there. - Never put essential information only in a tooltip: it doesn't open on touch screens.
- For text that explains something, use a Popover instead.
- Wrap a toolbar, or the whole app, in one
Tooltip.Provider. - On a trigger that also opens a Menu, Popover or Dialog, stack the triggers:
<Tooltip.Trigger render={<Menu.Trigger render={<Button … />} />} />. See the recipe.
primarybackground,on-primarytext,label-sm,radius-md,space-1byspace-2padding, at mosttooltip-widthwide.- Waits 400ms on hover before opening; keyboard focus has no opening delay. Opening and closing use the shared Motion fade and
space-1offset overduration-fade. Both transitions are disabled under reduced motion. Moving between tooltips in a group skips the delay and replayed entrance.