Tooltip
A short plain-text hint on hover or keyboard focus. What an icon button does, or the full text of a label that's cut off. A few words, never interactive.
Usage
pnpm dlx shadcn@latest add tooltipThen replace components/ui/tooltip.tsx with the Matrix version, and wrap your app once in TooltipProvider:
// app/layout.tsx
import { TooltipProvider } from '@/components/ui/tooltip';
<body>
<TooltipProvider>{children}</TooltipProvider>
</body>One shared provider sets the timing for every tooltip: 500ms before the first one opens, then instant while you move to the next trigger within 300ms, so a toolbar reads as one surface. Don't add a provider per tooltip; that breaks the instant follow-up.
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" square aria-label="Copy link"><Link2 /></Button>
</TooltipTrigger>
<TooltipContent>Copy link</TooltipContent>
</Tooltip>At a glance
A dark neutral bubble with 12px medium text, 6px from its trigger, with an arrow pointing at it. It opens on the top by default and flips to the other side when there's no room.
Variants
A disabled button doesn't receive hover or focus, so put the tooltip on a focusable wrapper. Use it to say why the action isn't available.
Behavior
Always a delay, then instant while scanning
500ms before the first tooltip, so moving the mouse across the page doesn't flash bubbles. After one has shown, the next opens immediately for 300ms.
Keyboard focus opens it too
Tabbing to a trigger shows its tooltip; Escape hides it. Screen readers read the tooltip as the trigger's description.
Hover only on touch
Phones and tablets have no hover, so a tooltip never appears there. Never put information only in a tooltip; the trigger must make sense without it (an icon button still needs its aria-label).
Never interactive
No links or buttons inside. If people need to click something in it, use a popover.
API reference
Prop
Type
Guidelines
- Give every icon-only button a tooltip with the same words as its
aria-label. - Keep it to a few words, in sentence case, without a full stop: "Copy link", not "Click here to copy the link."
- Add the keyboard shortcut when there is one.
- Don't repeat a visible label; a button that says "Save" doesn't need a "Save" tooltip.
- Don't put essential information or actions in a tooltip; touch users never see it.