Tooltip
A label that provides information on hover or focus.
Anatomy
<Tooltip.Root>
<Tooltip.Trigger />
<Tooltip.Positioner>
<Tooltip.Arrow>
<Tooltip.ArrowTip />
</Tooltip.Arrow>
<Tooltip.Content />
</Tooltip.Positioner>
</Tooltip.Root>
Examples
Controlled
Pass open to control the tooltip.
Root Provider
Use RootProvider with the useTooltip hook to access the state and methods from outside the component.
Arrow
Add Tooltip.Arrow and Tooltip.ArrowTip to point at the trigger.
Delay
Set openDelay and closeDelay.
Positioning
Use positioning to place the tooltip relative to the trigger.
Follow Cursor
Use positioning.getAnchorElement with the pointer position to make the tooltip follow the cursor.
Context
Read the state and methods with Tooltip.Context or the useTooltipContext hook.
Within Fixed Containers
Inside a fixed-position container, set positioning.strategy to "fixed".
Multiple Triggers
Pass a value to each Tooltip.Trigger to share one tooltip. It moves to the hovered trigger without closing.
With Checkbox
Merge Tooltip.Trigger onto Checkbox.Root with the render API.
With Menu Trigger
Merge Tooltip.Trigger onto Menu.Trigger.
With Menu Item
Put a tooltip on a disabled Menu.Item. Portal it so the menu does not clip it.
With Dialog
Merge Tooltip.Trigger onto Dialog.Trigger.
With Popover
Merge Tooltip.Trigger onto Popover.Trigger.
API Reference
Props
Root
| Prop | Default | Type |
|---|---|---|
aria-label | stringCustom label for the tooltip. | |
closeDelay | 150 | numberThe close delay of the tooltip. |
closeOnClick | true | booleanWhether the tooltip should close on click |
closeOnEscape | true | booleanWhether to close the tooltip when the Escape key is pressed. |
closeOnPointerDown | true | booleanWhether to close the tooltip on pointerdown. |
closeOnScroll | true | booleanWhether the tooltip should close on scroll |
defaultOpen | booleanThe initial open state of the tooltip when rendered. Use when you don't need to control the open state of the tooltip. | |
defaultTriggerValue | stringThe initial trigger value when rendered. Use when you don't need to control the trigger value. | |
disabled | booleanWhether the tooltip is disabled | |
hideMode | 'display-none' | HideModeHow to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+. |
id | stringThe unique identifier of the machine. | |
ids | ElementIdsThe ids of the elements in the tooltip. Useful for composition. | |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
interactive | false | booleanWhether the tooltip's content is interactive. In this mode, the tooltip will remain open when user hovers over the content. |
lazyMount | false | booleanWhether to enable lazy mounting |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
onOpenChange | (details: OpenChangeDetails) => voidFunction called when the tooltip is opened. | |
onTriggerValueChange | (details: TriggerValueChangeDetails) => voidFunction called when the trigger value changes. | |
open | booleanThe controlled open state of the tooltip | |
openDelay | 400 | numberThe open delay of the tooltip. |
positioning | PositioningOptionsThe user provided options used to position the popover content | |
present | booleanWhether the node is present (controlled by the user) | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
triggerValue | stringThe controlled trigger value | |
unmountOnExit | false | booleanWhether to unmount on exit. |
Arrow
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-tooltip-arrow] | <uid> |
[data-state] | "open" | "closed" |
| CSS Variable | Description |
|---|---|
--arrow-size | The size of the arrow |
--arrow-size-half | Half the size of the arrow |
--arrow-background | Use this variable to style the arrow background |
--arrow-offset | The offset position of the arrow |
ArrowTip
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Content
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<TooltipContentState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-tooltip-content] | <uid> |
[data-value] | The value of the item |
[data-state] | "open" | "closed" |
[data-instant] | |
[data-placement] | The placement of the content |
[data-side] | The side of the trigger that the content is positioned on |
[data-activation-direction] |
Positioner
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-tooltip-positioner] | <uid> |
[data-transitioning] |
| CSS Variable | Description |
|---|---|
--reference-width | The width of the reference element |
--reference-height | The height of the root |
--available-width | The available width in viewport |
--available-height | The available height in viewport |
--x | The x position for transform |
--y | The y position for transform |
--transform-origin | The transform origin for animations |
RootProvider
| Prop | Default | Type |
|---|---|---|
value | UseTooltipReturn | |
hideMode | 'display-none' | HideModeHow to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+. |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
lazyMount | false | booleanWhether to enable lazy mounting |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
present | booleanWhether the node is present (controlled by the user) | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
Trigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<TooltipTriggerState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
value | stringThe value that identifies this specific trigger |
| Attribute | Description |
|---|---|
[data-tooltip-trigger] | <uid> |
[data-value] | The value of the item |
[data-current] | Present when current |
[data-expanded] | Present when expanded |
[data-state] | "open" | "closed" |
Context
API
| Property | Type |
|---|---|
open | booleanWhether the tooltip is open. |
setOpen | (open: boolean, reason?: OpenChangeReason) => voidFunction to open the tooltip. |
triggerValue | string | nullThe trigger value |
setTriggerValue | (value: string | null) => voidFunction to set the trigger value |
activationDirection | PopupActivationDirection | nullWhere the current trigger sits relative to the previous one, after switching triggers while open |
getContentValues | () => string[]Returns the trigger values whose content to render: the current one, plus the previous one while it animates out after a switch. Oldest first. |
reposition | (options?: Partial<PositioningOptions>) => voidFunction to reposition the popover |
getTriggerState | (props?: TriggerProps) => TriggerStateReturns the state of a specific trigger, including whether it's the currently active one |
getContentState | (props?: ContentProps) => ContentStateReturns the state of the content |
getViewportState | () => ViewportStateReturns the state of the viewport |
Accessibility
Complies with the Tooltip WAI-ARIA design pattern.
Keyboard Support
| Key | Description |
|---|---|
Tab | Opens/closes the tooltip without delay. |
Escape | If open, closes the tooltip without delay. |