Overlays
Tooltip
Free15.0 KB gzippedA short, non-interactive label or description that appears on hover and on keyboard focus. Follows the WAI-ARIA tooltip pattern and WCAG 1.4.13: it can be dismissed with Escape, the pointer can move onto it, and it stays open until the pointer or focus leaves. Use Popover for interactive content.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Escape · Full report
Import
import { Tooltip, TooltipProvider } from "@vjdesigns/vjdesigns-ui";
Importing only Tooltip adds about 15.0 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Icon buttons
Tooltips show on hover and keyboard focus, and hide on Escape. relationship="label" makes the tooltip the button's accessible name, which suits icon-only buttons.
import {
CopyIcon,
EditIcon,
Flex,
IconButton,
Tooltip,
TrashIcon,
} from "@vjdesigns/vjdesigns-ui";
export function IconButtons() {
return (
<Flex gap={2}>
<Tooltip content="Edit" relationship="label">
<IconButton aria-label="Edit" variant="ghost" tone="neutral">
<EditIcon />
</IconButton>
</Tooltip>
<Tooltip content="Duplicate" relationship="label" shortcut={["mod", "D"]}>
<IconButton aria-label="Duplicate" variant="ghost" tone="neutral">
<CopyIcon />
</IconButton>
</Tooltip>
<Tooltip content="Delete" relationship="label" tone="primary">
<IconButton aria-label="Delete" variant="ghost" tone="danger">
<TrashIcon />
</IconButton>
</Tooltip>
</Flex>
);
}
Placement
By default the tooltip describes its trigger (aria-describedby) and sits above it.
import { Button, Flex, Tooltip } from "@vjdesigns/vjdesigns-ui";
export function Placement() {
return (
<Flex gap={3} wrap="wrap" justify="center">
{(["top", "right", "bottom", "left"] as const).map((placement) => (
<Tooltip key={placement} content={`Shown on the ${placement}`} placement={placement}>
<Button variant="outline" tone="neutral">
{placement}
</Button>
</Tooltip>
))}
</Flex>
);
}
Accessibility
A tooltip opens on keyboard focus as well as hover. For an icon-only button, relationship="label" makes the tooltip the button's name; otherwise it's a description. Never put links or buttons inside: a tooltip can't take focus.
import {
Button,
CopyIcon,
Flex,
IconButton,
Tooltip,
TrashIcon,
} from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Flex gap={3}>
<Tooltip content="Copy link" relationship="label">
<IconButton aria-label="Copy link" variant="ghost" tone="neutral">
<CopyIcon />
</IconButton>
</Tooltip>
<Tooltip content="Deleted files stay in the trash for 30 days.">
<Button variant="outline" tone="danger" startIcon={<TrashIcon />}>
Delete
</Button>
</Tooltip>
</Flex>
);
}
Translated
Tooltip text is your own content; LocaleProvider sets lang, so it's read in Chinese, and placement mirrors in right-to-left locales.
import {
CopyIcon,
EditIcon,
Flex,
IconButton,
Tooltip,
LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import zhHans from "@vjdesigns/vjdesigns-ui/locales/zh-Hans";
export function Translated() {
return (
<LocaleProvider locale="zh-Hans" messages={zhHans}>
<Flex gap={3}>
<Tooltip content="编辑" relationship="label">
<IconButton aria-label="编辑" variant="ghost" tone="neutral">
<EditIcon />
</IconButton>
</Tooltip>
<Tooltip content="复制链接" relationship="label">
<IconButton aria-label="复制链接" variant="ghost" tone="neutral">
<CopyIcon />
</IconButton>
</Tooltip>
</Flex>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Icon buttons
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// IconButtons is the "Icon buttons" example above.
<LocaleProvider locale="ar" messages={ar}>
<IconButtons />
</LocaleProvider>
API reference
Tooltip
| Prop | Type | Default |
|---|---|---|
childrenRequiredThe trigger: exactly one focusable element (a Disabled elements fire no pointer or focus events, so a | ReactElement | — |
contentRequiredShort, plain text describing or naming the trigger. Never put interactive content (links, buttons, inputs) here: a tooltip can't receive focus. Use a Popover for that. A dev-mode warning fires if focusable content is found. | ReactNode | — |
shortcutKeys of a keyboard shortcut, rendered as a | KbdShortcutProps["keys"] | — |
placementPreferred side and alignment, or a logical | TooltipPlacement | "top" |
offsetGap between the trigger and the tooltip, in px. | number | 8 |
openControlled open state. | boolean | — |
defaultOpenInitial open state when uncontrolled. | boolean | false |
onOpenChangeCalled with the next open state. | (open: boolean) => void | — |
delayDelay before opening on hover or keyboard focus, in ms. Falls back to | number | — |
closeDelayDelay before closing after the pointer leaves, in ms; gives the pointer time to reach the tooltip. Falls back to | number | — |
disabledNever open, and don't wire | boolean | false |
showArrowShow an arrow pointing at the trigger. | boolean | true |
toneColor. | "neutral""primary" | "neutral" |
relationshipHow the tooltip relates to the trigger: | "description""label" | "description" |
classNameClass name for the tooltip element. | string | — |
styleStyle for the tooltip element. Positioning styles are applied on top. | CSSProperties | — |
idId for the tooltip element. Generated when omitted. | string | — |
TooltipProvider
Optional. Sets shared timing for the tooltips inside it. Tooltips work without a provider, using the defaults.
| Prop | Type | Default |
|---|---|---|
delayDefault open delay for every tooltip inside, in ms. | number | 400 |
closeDelayDefault close delay for every tooltip inside, in ms. | number | 100 |
skipDelayDurationAfter a tooltip closes, other tooltips open instantly (no | number | 300 |
children | ReactNode | — |
See what changed in each version in the Changelog.
Accessibility report
Tooltip targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Tab | Focusing the trigger shows the tooltip. |
| Escape | Hides it without moving focus. |
Stays open while the pointer is over the trigger or the tooltip, or the trigger has focus (WCAG 1.4.13).
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Tooltip | tooltip | — |
| Trigger | Its own | aria-describedby → tooltip (or aria-labelledby for an icon button's name) |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |