Tooltip
A visual hint that labels a control on hover or keyboard focus.
Usage guidelines
- Use
Tooltipfor a supplementary visual label on a control that already has a primary action and an accessible name. When the trigger's only job is to open an explanation, useInfotip. - Tooltip content is not the trigger's accessible name. An icon-only trigger such as
IconButtonkeeps its ownaria-label, and a trigger with visible text keeps that text as its name. - Do not put anything users must reach in a tooltip. Touch devices do not open it and assistive technology does not read it, so essential, structured or interactive content goes in a
Popoveror anInfotip. - Text length alone does not decide between
TooltipandInfotip. Decide by what the trigger does and whether the content must be reachable. TooltipProvidershares open and close delays, so moving between neighboring triggers opens the next tooltip without waiting again. Wrap the application in one provider at its root; feature code composesTooltipwithout adding its own.- Compose the trigger through
renderso the control keeps its own component, such asIconButtonorButton.
Anatomy
TooltipContent bundles the portal, positioner and styled popup. side, align, sideOffset and alignOffset place it against the trigger.
Examples
Keyboard shortcut
A tooltip can show the control's shortcut next to its label with Kbd. The label in the tooltip repeats the trigger's aria-label. Assistive technology does not read the tooltip, so a trigger whose shortcut the feature handles also sets aria-keyshortcuts, such as Meta+B. This example only displays the keys and binds no shortcut, so it leaves aria-keyshortcuts off.
Text trigger
A button with visible text keeps that text as its name, and the tooltip adds a detail the user can afford to miss.
Disabled trigger
A natively disabled button cannot receive keyboard focus. Pair disabled with focusableWhenDisabled on Button so both pointer and keyboard users can inspect why the action is unavailable.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves focus to the trigger and opens its tooltip. |
| Escape | Closes the tooltip while focus stays on the trigger. |
API reference
Tooltip
Groups a trigger and floating tooltip popup. Doesn't render its own HTML element.
Wrap the application in TooltipProvider to share open and close delays across tooltips.
| Prop | Type | Default | Details |
|---|---|---|---|
defaultOpen | boolean | false | |
open | boolean | No default | |
onOpenChange | ((open: boolean, eventDetails: BaseTooltip.Root.ChangeEventDetails) => void) | No default | |
onOpenChangeComplete | ((open: boolean) => void) | No default | |
disableHoverablePopup | boolean | false | |
trackCursorAxis | 'both' | 'none' | 'x' | 'y' | 'none' | |
actionsRef | React.RefObject<TooltipRootActions | null> | No default | |
disabled | boolean | false | |
children | PayloadChildRenderFunction<Payload> | React.ReactNode | No default | |
triggerId | string | null | No default | |
defaultTriggerId | string | null | No default | |
TooltipContent
A styled tooltip popup bundled with a portal and positioner. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
sideOffset | number | OffsetFunction | 8 | |
children required | React.ReactNode | No default | |
className | string | ((state: TooltipPopupState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, TooltipPopupState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: TooltipPopupState) => React.CSSProperties | undefined) | No default | |
align | 'center' | 'end' | 'start' | 'center' | |
alignOffset | number | OffsetFunction | 0 | |
side | 'bottom' | 'inline-end' | 'inline-start' | 'left' | 'right' | 'top' | 'top' | |
| Attribute | Description |
|---|---|
data-open | Present when the tooltip is open. |
data-closed | Present when the tooltip is closed. |
data-starting-style | Present when the tooltip begins animating in. |
data-ending-style | Present when the tooltip is animating out. |
data-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
data-instant | Values: Present if animations should be instant. |
| Variable | Description |
|---|---|
--available-width | Values: The available width between the trigger and the edge of the viewport. |
--available-height | Values: The available height between the trigger and the edge of the viewport. |
--anchor-width | Values: The anchor's width. |
--anchor-height | Values: The anchor's height. |
--transform-origin | Values: The coordinates that this element is anchored to. Used for animations and transitions. |
--positioner-width | Values: The width of the tooltip's positioner. It is important to set |
--positioner-height | Values: The height of the tooltip's positioner. It is important to set |
TooltipProvider
Provides a shared delay for multiple tooltips. The grouping logic ensures that once a tooltip becomes visible, the adjacent tooltips will be shown instantly.
| Prop | Type | Default | Details |
|---|---|---|---|
children | React.ReactNode | No default | |
delay | number | No default | |
closeDelay | number | No default | |
timeout | number | 400 | |
TooltipTrigger
An element to attach the tooltip to. Renders a <button> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: TooltipTriggerState) => string | undefined) | No default | |
payload | Payload | No default | |
delay | number | 600 | |
closeOnClick | boolean | true | |
closeDelay | number | 0 | |
disabled | boolean | false | |
render | ComponentRenderFn<HTMLProps, TooltipTriggerState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: TooltipTriggerState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-popup-open | Present when the corresponding tooltip is open. |
data-trigger-disabled | Present when the trigger is disabled, either by the |