Tooltip
A popup that appears when an element is hovered or focused, showing a hint for sighted users.
API reference
Import the component and assemble its parts:
import { Tooltip } from '@base-ui-components/react/tooltip';
<Tooltip.Provider> <Tooltip.Root> <Tooltip.Trigger /> <Tooltip.Portal> <Tooltip.Positioner> <Tooltip.Popup> <Tooltip.Arrow /> </Tooltip.Popup> </Tooltip.Positioner> </Tooltip.Portal> </Tooltip.Root></Tooltip.Provider>
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.
Prop | Type | Default | |
---|---|---|---|
delay |
|
| |
closeDelay |
|
| |
timeout |
|
|
Root
Groups all parts of the tooltip. Doesn’t render its own HTML element.
Prop | Type | Default | |
---|---|---|---|
defaultOpen |
|
| |
open |
|
| |
onOpenChange |
|
| |
trackCursorAxis |
|
| |
delay |
|
| |
closeDelay |
|
| |
hoverable |
|
|
Trigger
An element to attach the tooltip to.
Renders a <button>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-popup-open | Present when the corresponding tooltip is open. |
Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>
.
Prop | Type | Default | |
---|---|---|---|
container |
|
| |
keepMounted |
|
|
Positioner
Positions the tooltip against the trigger.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
align |
|
| |
alignOffset |
|
| |
side |
|
| |
sideOffset |
|
| |
arrowPadding |
|
| |
anchor |
|
| |
collisionBoundary |
|
| |
collisionPadding |
|
| |
sticky |
|
| |
positionMethod |
|
| |
className |
|
| |
keepMounted |
|
| |
render |
|
|
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-side | Indicates which side the tooltip is positioned relative to the trigger. |
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. |
Popup
A container for the tooltip contents.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the tooltip is open. | |
data-closed | Present when the tooltip is closed. | |
data-instant | Indicates the instant type of the tooltip popup. | |
data-side | Indicates which side the tooltip 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. |
Arrow
Displays an element positioned against the tooltip anchor.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
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-anchor-hidden | Present when the anchor is hidden. | |
data-side | Indicates which side the tooltip is positioned relative to the trigger. |