Overlays
Tooltip and HelpTooltip
Visibility
When to use
- To label an icon-only button or to explain an unfamiliar term.
- To give a short optional clarification that is not needed to complete the task.
HelpTooltip— for a standard help icon next to a field or a setting.
When not to use
- Do not hide a required instruction, an error or the only name of an action: they must be visible or programmatically tied to the control.
- Use
Popoverfor complex interactive content andAlertfor a status message. UseHoverCardfor a preview with markup (an avatar, a title, a couple of lines) on hover over a link or a name. - Do not create a
TooltipProviderfor every button.
Minimal example
<Tooltip content="Delete the selection">
<Button iconOnly aria-label="Delete" icon={<DeleteIcon />} />
</Tooltip>Public API
Tooltip accepts content, a single children: ReactElement, side, align
and delayDuration. An empty content returns the child without a
wrapper. The child must accept a ref, because it becomes the trigger.
TooltipContent accepts the Radix Content props; its sideOffset is 6 by
default. TooltipProvider, TooltipRoot and TooltipTrigger export the Radix
primitives for the compound API.
Accessibility and keyboard
The tooltip opens on focus too, not only on hover. An icon-only trigger must still
have its own aria-label: a tooltip is not a reliable accessible name for a
button. Put one provider at the root so that the shared delay and the transition
between tooltips work consistently. See
the Tooltip source and
HelpTooltip.
Good examples
- A delete icon with an
aria-labeland a clarifying tooltip. content={condition ? text : undefined}without branching the DOM by hand.HelpTooltipnext to an unclear parameter, but not instead of itslabel.
Anti-patterns
- A tooltip on a non-focusable
spanas the only way to read the action. - Multi-paragraph text, buttons or a form inside a tooltip.
- A nested provider in a library component.
Related sources and Storybook
src/components/overlays/Tooltip.tsx,src/components/overlays/HelpTooltip.tsxsrc/components/overlays/Tooltip.stories.tsx
TypeScript types
TooltipProps
Prop
Type
HelpTooltipProps
Prop
Type