Tooltip
A popup that appears when an element is hovered or focused, showing a hint for sighted users.
View as MarkdownUsage guidelines
- Prefer using tooltips as visual labels only: Tooltips should act as supplementary visual labels for sighted mouse and keyboard users. Tooltips alone are not accessible to touch or screen reader users. See Alternatives to tooltips for more details.
- Provide an accessible name for the trigger: Tooltips are visual-only elements and are not a replacement for labeling the trigger. The tooltip’s trigger must have an
aria-labelattribute that closely matches the tooltip’s content to ensure consistency for screen reader users.
Anatomy
Import the component and assemble its parts:
Alternatives to tooltips
Tooltips should be supplementary popups that provide non-essential clarity in high-density UIs. A user should not miss critical information if they never see a tooltip.
Tooltips don’t work well with touch input. Unlike mouse pointers with hover capability, there’s no easily discoverable way to reveal a tooltip before tapping its trigger on a touch device.
iOS doesn’t provide a system-standard, touch-friendly tooltip affordance, while Android may show a tooltip on long press. However, on the web, long press is often used to trigger contextual menus in the browser, which can lead to potential conflicts. For this reason, tooltips are disabled on touch devices.
Infotips
Popups that open when hovering an info icon should use Popover with the openOnHover prop on the trigger instead of a tooltip. This way, touch users and screen reader users can access the content.
To know when to reach for a popover instead of a tooltip, consider the purpose of the trigger element: If the trigger’s purpose is to open the popup itself, it’s a popover. If the trigger’s purpose is unrelated to opening the popup, it’s a tooltip.
Description text
Tooltips are designed for sighted users and are not a reliable way to deliver important information to touch users or assistive technologies. If the description is important to understanding the element, don’t hide it behind a tooltip — use inline text or Popover if space is limited, so the information is accessible to everyone.
Since tooltips serve sighted mouse and keyboard users, iconography should clearly communicate the purpose of icon-only triggers, especially on mobile where the text label may not be visible.
If the description is not critical, a tooltip can still be used to provide extra clarity for sighted mouse or keyboard users.
Contextual feedback messages
Use the Toast component’s anchoring ability for more ergonomic DX, to ensure the message is announced to screen readers, and to support complex content.
Examples
Detached triggers
A tooltip can be controlled by a trigger located either inside or outside the <Tooltip.Root> component.
For simple, one-off interactions, place the <Tooltip.Trigger> inside <Tooltip.Root>, as shown in the example at the top of this page.
However, if defining the tooltip’s content next to its trigger is not practical, you can use a detached trigger.
This involves placing the <Tooltip.Trigger> outside of <Tooltip.Root> and linking them with a handle created by the Tooltip.createHandle() function.
Multiple triggers
A single tooltip can be opened by multiple trigger elements.
You can achieve this by using the same handle for several detached triggers, or by placing multiple <Tooltip.Trigger> components inside a single <Tooltip.Root>.
The tooltip can render different content depending on which trigger opened it.
This is achieved by passing a payload to the <Tooltip.Trigger> and using the function-as-a-child pattern in <Tooltip.Root>.
The payload can be strongly typed by providing a type argument to the createHandle() function:
Controlled mode with multiple triggers
You can control the tooltip’s open state externally using the open and onOpenChange props on <Tooltip.Root>.
This allows you to manage the tooltip’s visibility based on your application’s state.
When using multiple triggers, you have to manage which trigger is active with the triggerId prop on <Tooltip.Root> and the id prop on each <Tooltip.Trigger>.
Note that there is no separate onTriggerIdChange prop.
Instead, the onOpenChange callback receives an additional argument, eventDetails, which contains the trigger element that initiated the state change.
Animating the Tooltip
You can animate a tooltip as it moves between different trigger elements. This includes animating its position, size, and content.
Position and Size
To animate the tooltip’s position, apply CSS transitions to the left, right, top, and bottom properties of the Positioner part.
To animate its size, transition the width and height of the Popup part.
Content
The tooltip also supports content transitions. This is useful when different triggers display different content within the same tooltip.
To enable content animations, wrap the content in the <Tooltip.Viewport> part.
This part provides features to create direction-aware animations.
It renders a div with a data-activation-direction attribute (left, right, up, or down) that indicates the new trigger’s position relative to the previous one.
Inside the <Tooltip.Viewport>, the content is further wrapped in divs with data attributes to help with styling:
data-current: The currently visible content when no transitions are present or the incoming content.data-previous: The outgoing content during a transition.
You can use these attributes to style the enter and exit animations.
API reference
Provider
Provides a shared delay for multiple tooltips. The grouping logic ensures that once a tooltip becomes visible, the adjacent tooltips will be shown instantly.
delaynumber—
- Name
- Description
How long to wait before opening a tooltip. Specified in milliseconds.
- Type
closeDelaynumber—
- Name
- Description
How long to wait before closing a tooltip. Specified in milliseconds.
- Type
timeoutnumber400
- Name
- Description
Another tooltip will open instantly if the previous tooltip is closed within this timeout. Specified in milliseconds.
- Type
- Default
400
childrenReact.ReactNode—
- Name
- Type
Tooltip.Provider.StateHide
Root
Groups all parts of the tooltip. Doesn’t render its own HTML element.
defaultOpenbooleanfalse
- Name
- Description
Whether the tooltip is initially open.
To render a controlled tooltip, use the
openprop instead.- Type
- Default
false
openboolean—
- Name
- Description
Whether the tooltip is currently open.
- Type
onOpenChangefunction—
- Name
- Description
Event handler called when the tooltip is opened or closed.
- Type
actionsRefReact.RefObject<Tooltip.Root.Actions | null>—
- Name
- Description
A ref to imperative actions.
unmount: Unmounts the tooltip popup.close: Closes the tooltip imperatively when called.
- Type
defaultTriggerIdstring | null—
- Name
- Description
ID of the trigger that the tooltip is associated with. This is useful in conjunction with the
defaultOpenprop to create an initially open tooltip.- Type
handleTooltip.Handle<Payload>—
- Name
- Description
A handle to associate the tooltip with a trigger. If specified, allows external triggers to control the tooltip’s open state. Can be created with the Tooltip.createHandle() method.
- Type
onOpenChangeCompletefunction—
- Description
Event handler called after any animations complete when the tooltip is opened or closed.
- Type
triggerIdstring | null—
- Name
- Description
ID of the trigger that the tooltip is associated with. This is useful in conjunction with the
openprop to create a controlled tooltip. There’s no need to specify this prop when the tooltip is uncontrolled (that is, when theopenprop is not set).- Type
trackCursorAxisUnion'none'
- Name
- Description
Determines which axis the tooltip should track the cursor on.
- Type
- Default
'none'
disabledbooleanfalse
- Name
- Description
Whether the tooltip is disabled.
- Type
- Default
false
disableHoverablePopupbooleanfalse
- Description
Whether the tooltip contents can be hovered without closing the tooltip.
- Type
- Default
false
children| React.ReactNode
| PayloadChildRenderFunction<Payload>—
| PayloadChildRenderFunction<Payload>
- Name
- Description
The content of the tooltip. This can be a regular React node or a render function that receives the
payloadof the active trigger.- Type
Tooltip.Root.StateHide
Tooltip.Root.ActionsHide
Tooltip.Root.ChangeEventReasonHide
Tooltip.Root.ChangeEventDetailsHide
Trigger
An element to attach the tooltip to.
Renders a <button> element.
closeOnClickbooleantrue
- Name
- Description
Whether the tooltip should close when this trigger is clicked.
- Type
- Default
true
handleTooltip.Handle<Payload>—
- Name
- Description
A handle to associate the trigger with a tooltip.
- Type
payloadPayload—
- Name
- Description
A payload to pass to the tooltip when it is opened.
- Type
disabledbooleanfalse
- Name
- Description
If
true, the tooltip will not open when interacting with this trigger. Note that this doesn’t apply thedisabledattribute to the trigger element. If you want to disable the trigger element itself, you can pass thedisabledprop to the trigger element via therenderprop.- Type
- Default
false
delaynumber600
- Name
- Description
How long to wait before opening the tooltip. Specified in milliseconds.
- Type
- Default
600
closeDelaynumber0
- Name
- Description
How long to wait before closing the tooltip. Specified in milliseconds.
- Type
- Default
0
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-popup-open
Present when the corresponding tooltip is open.
data-trigger-disabled
Present when the trigger is disabled, either by the disabled prop or by a parent <Tooltip.Root> component.
| Attribute | Description | |
|---|---|---|
data-popup-open | Present when the corresponding tooltip is open. | |
data-trigger-disabled | Present when the trigger is disabled, either by the | |
Tooltip.Trigger.StateHide
Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>.
Renders a <div> element.
containerUnion—
- Name
- Description
A parent element to render the portal element into.
- Type
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
keepMountedbooleanfalse
- Name
- Description
Whether to keep the portal mounted in the DOM while the popup is hidden.
- Type
- Default
false
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
Tooltip.Portal.StateHide
Positioner
Positions the tooltip against the trigger.
Renders a <div> element.
disableAnchorTrackingbooleanfalse
- Description
Whether to disable the popup from tracking any layout shift of its positioning anchor.
- Type
- Default
false
alignAlign'center'
- Name
- Description
How to align the popup relative to the specified side.
- Type
- Default
'center'
alignOffsetnumber | OffsetFunction0
- Name
- Description
Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment.
The function takes a
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side.
- Type
- Default
0- Example
sideSide'top'
- Name
- Description
Which side of the anchor element to align the popup against. May automatically change to avoid collisions.
- Type
- Default
'top'
sideOffsetnumber | OffsetFunction0
- Name
- Description
Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment.
The function takes a
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side.
- Type
- Default
0- Example
arrowPaddingnumber5
- Name
- Description
Minimum distance to maintain between the arrow and the edges of the popup.
Use it to prevent the arrow element from hanging out of the rounded corners of a popup.
- Type
- Default
5
anchorUnion—
- Name
- Description
An element to position the popup against. By default, the popup will be positioned against the trigger.
- Type
collisionAvoidanceCollisionAvoidance—
- Description
Determines how to handle collisions when positioning the popup.
sidecontrols overflow on the preferred placement axis (top/bottomorleft/right):'flip': keep the requested side when it fits; otherwise try the opposite side (topandbottom, orleftandright).'shift': never change side; keep the requested side and move the popup within the clipping boundary so it stays visible.'none': do not correct side-axis overflow.
aligncontrols overflow on the alignment axis (start/center/end):'flip': keep side, but swapstartandendwhen the requested alignment overflows.'shift': keep side and requested alignment, then nudge the popup along the alignment axis to fit.'none': do not correct alignment-axis overflow.
fallbackAxisSidecontrols fallback behavior on the perpendicular axis when the preferred axis cannot fit:'start': allow perpendicular fallback and try the logical start side first (topbeforebottom, orleftbeforerightin LTR).'end': allow perpendicular fallback and try the logical end side first (bottombeforetop, orrightbeforeleftin LTR).'none': do not fallback to the perpendicular axis.
When
sideis'shift', explicitly settingalignonly supports'shift'or'none'. Ifalignis omitted, it defaults to'flip'.- Type
- Example
collisionBoundaryBoundary'clipping-ancestors'
- Description
An element or a rectangle that delimits the area that the popup is confined to.
- Type
- Default
'clipping-ancestors'
collisionPaddingPadding5
- Name
- Description
Additional space to maintain from the edge of the collision boundary.
- Type
- Default
5
stickybooleanfalse
- Name
- Description
Whether to maintain the popup in the viewport after the anchor element was scrolled out of view.
- Type
- Default
false
positionMethod'absolute' | 'fixed''absolute'
- Name
- Description
Determines which CSS
positionproperty to use.- Type
- Default
'absolute'
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-open
Present when the tooltip is open.
data-closed
Present when the tooltip is closed.
data-anchor-hidden
Present when the anchor is hidden.
data-align
Indicates how the popup is aligned relative to specified side.
data-side
Indicates which side the popup is positioned relative to the trigger.
| Attribute | Description | |
|---|---|---|
data-open | Present when the tooltip is open. | |
data-closed | Present when the tooltip is closed. | |
data-anchor-hidden | Present when the anchor is hidden. | |
data-align | Indicates how the popup is aligned relative to specified side. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
--anchor-height
The anchor’s height.
--anchor-width
The anchor’s width.
--available-height
The available height between the trigger and the edge of the viewport.
--available-width
The available width between the trigger and the edge of the viewport.
--transform-origin
The coordinates that this element is anchored to. Used for animations and transitions.
| CSS Variable | Description | |
|---|---|---|
--anchor-height | The anchor’s height. | |
--anchor-width | The anchor’s width. | |
--available-height | The available height between the trigger and the edge of the viewport. | |
--available-width | The available width between the trigger and the edge of the viewport. | |
--transform-origin | The coordinates that this element is anchored to. Used for animations and transitions. | |
Tooltip.Positioner.PropsHide
Re-Export of Positioner props as TooltipPositionerProps
Tooltip.Positioner.StateHide
Popup
A container for the tooltip contents.
Renders a <div> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-open
Present when the tooltip is open.
data-closed
Present when the tooltip is closed.
data-align
Indicates how the popup is aligned relative to specified side.
data-instant
Present if animations should be instant.
data-side
Indicates which side the popup is positioned relative to the trigger.
data-starting-style
Present when the tooltip is animating in.
data-ending-style
Present when the tooltip is animating out.
| Attribute | Description | |
|---|---|---|
data-open | Present when the tooltip is open. | |
data-closed | Present when the tooltip is closed. | |
data-align | Indicates how the popup is aligned relative to specified side. | |
data-instant | Present if animations should be instant. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
data-starting-style | Present when the tooltip is animating in. | |
data-ending-style | Present when the tooltip is animating out. | |
Tooltip.Popup.StateHide
Arrow
Displays an element positioned against the tooltip anchor.
Renders a <div> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-open
Present when the tooltip is open.
data-closed
Present when the tooltip is closed.
data-uncentered
Present when the tooltip arrow is uncentered.
data-align
Indicates how the popup is aligned relative to specified side.
data-instant
Present if animations should be instant.
data-side
Indicates which side the popup is positioned relative to the trigger.
| Attribute | Description | |
|---|---|---|
data-open | Present when the tooltip is open. | |
data-closed | Present when the tooltip is closed. | |
data-uncentered | Present when the tooltip arrow is uncentered. | |
data-align | Indicates how the popup is aligned relative to specified side. | |
data-instant | Present if animations should be instant. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
Tooltip.Arrow.StateHide
createHandle
Creates a new handle to connect a Tooltip.Root with detached Tooltip.Trigger components.
Return value
Handle
A handle to control a tooltip imperatively and to associate detached triggers with it.
Properties
isOpenreadonly
- Name
- Description
Indicates whether the tooltip is currently open.
- Type
- Modifiers
readonly
Methods
open(triggerId)
- Name
- Description
Opens the tooltip and associates it with the trigger with the given ID. The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
This method should only be called in an event handler or an effect (not during rendering).
- Parameters
triggerId—ID of the trigger to associate with the tooltip.
- Returns
close()
- Name
- Description
Closes the tooltip.
- Returns