Tooltip
A short label that appears on hover or keyboard focus, positioned automatically, with an optional arrow.
// Radix — @radix-ui/react-tooltip
import { Tooltip } from "@shavin/ui";Icon buttons
The common case: a short hint on a button that shows only an icon. The tooltip does not name the button, so the button still needs its own aria-label.
import { IconButton, Icon, Tooltip } from "@shavin/ui";
<Tooltip content="Download statement">
<IconButton variant="ghost" aria-label="Download statement">
<Icon name="Download" size="sm" color="inherit" />
</IconButton>
</Tooltip>
<Tooltip content="Print">
<IconButton variant="ghost" aria-label="Print">
<Icon name="Printer" size="sm" color="inherit" />
</IconButton>
</Tooltip>Side
side picks where the tooltip prefers to sit: top (default), right, bottom or left. It flips to the opposite side when there is no room.
<Tooltip content="Above" side="top"><Button variant="outline">Top</Button></Tooltip>
<Tooltip content="To the right" side="right"><Button variant="outline">Right</Button></Tooltip>
<Tooltip content="Below" side="bottom"><Button variant="outline">Bottom</Button></Tooltip>
<Tooltip content="To the left" side="left"><Button variant="outline">Left</Button></Tooltip>Delay
delayDuration is the hover time in milliseconds before the tooltip opens. Default 300. Keyboard focus opens it straight away.
<Tooltip content="Opens at once" delayDuration={0}>
<Button variant="outline">0 ms</Button>
</Tooltip>
<Tooltip content="Opens after 700 ms" delayDuration={700}>
<Button variant="outline">700 ms</Button>
</Tooltip>Tone
auto (default) uses the theme's tooltip colours. dark and light force a fixed contrast, for a tooltip that must stand out from the surface behind it.
<Tooltip content="Follows the theme" tone="auto">…</Tooltip>
<Tooltip content="Always dark" tone="dark">…</Tooltip>
<Tooltip content="Always light" tone="light">…</Tooltip>When to use it
Keep tooltip text to a few words; it wraps at 240px. Tooltips do not open on touch screens and are not read as part of the button's name, so never put the only copy of something important in one, and never put links or buttons inside. For rich content someone can point at, use HoverCard; for content people open on purpose, use Popover.
Accessibility
The trigger is described by the tooltip (aria-describedby) while it is open. children must be a single element that forwards its ref, such as Button or IconButton; a plain component that does not forward refs will not get the hover and focus handlers.
Keyboard
| Key | Action |
|---|---|
| Tab | Focusing the trigger opens the tooltip. |
| Escape | Closes the tooltip. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| content* | ReactNode | — | Tooltip popover label content. |
| children* | ReactElement | — | Trigger element (must support forwardRef). |
| side | "top" | "right" | "bottom" | "left" | top | Placement side (top, right, bottom, left). Default top. |
| delayDuration | number | 300 | Open delay duration in milliseconds. Default 300. |
| tone | "auto" | "dark" | "light" | auto | Color tone: auto (theme default), dark, or light. Default auto. |
| className | string | — | Optional custom CSS class name. |
| open | boolean | — | Controlled open state (optional). |
| onOpenChange | (open: boolean) => void | — | Called when the tooltip wants to open or close (hover, focus, Escape, outside press). |
* required