Tooltip

A popup that appears when an element is hovered or focused, showing a hint for sighted users.

Accessibility guidelines

To ensure that tooltips are accessible and helpful, follow these guidelines:

  • Provide an accessible name for the trigger: The tooltip’s trigger must have a meaningful label. This can be its visible text or an aria-label/aria-labelledby attribute. The label should closely match the tooltip’s content to ensure consistency for screen reader users.
  • Avoid tooltips for critical information: Tooltips work well for enhancing UI clarity (like labeling icon buttons) but should not be the sole means of conveying important information. Since tooltips do not appear on touch devices, consider using a Popover for essential content.
  • Avoid tooltips for “infotips”: If your tooltip is attached to an “info icon” button whose only purpose is to show the tooltip, opt for Popover and add the openOnHover prop instead. Tooltips should describe an element that performs an action separate from opening the tooltip itself.

API reference

Import the component and assemble its parts:

Anatomy
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.

PropTypeDefault
delay

number

undefined

closeDelay

number

undefined

timeout

number

400

Root

Groups all parts of the tooltip. Doesn’t render its own HTML element.

PropTypeDefault
defaultOpen

boolean

false

open

boolean

undefined

onOpenChange

(open, event, reason) => void

undefined

action

{ current: { unmount: func } }

undefined

onOpenChangeComplete

(open) => void

undefined

trackCursorAxis

'none' | 'x' | 'y' | 'both'

'none'

delay

number

600

closeDelay

number

0

hoverable

boolean

true

Trigger

An element to attach the tooltip to. Renders a <button> element.

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-popup-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>.

PropTypeDefault
container

React.Ref | HTMLElement | null

undefined

keepMounted

boolean

false

Positioner

Positions the tooltip against the trigger. Renders a <div> element.

PropTypeDefault
align

'start' | 'center' | 'end'

'center'

alignOffset

number | (data) => number

0

side

| 'bottom'
| 'inline-end'
| 'inline-start'
| 'left'
| 'right'
| 'top'

'top'

sideOffset

number | (data) => number

0

arrowPadding

number

5

anchor

| React.Ref
| Element
| VirtualElement
| (() => Element | VirtualElement | null)
| null

undefined

collisionBoundary

| 'clipping-ancestors'
| Element
| Element[]
| Rect

'clipping-ancestors'

collisionPadding

number | Rect

5

sticky

boolean

false

positionMethod

'absolute' | 'fixed'

'absolute'

trackAnchor

boolean

true

className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-open
data-closed
data-anchor-hidden
data-side
CSS Variable
Description
--anchor-height
--anchor-width
--available-height
--available-width
--transform-origin

A container for the tooltip contents. Renders a <div> element.

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-open
data-closed
data-instant
data-side
data-starting-style
data-ending-style

Arrow

Displays an element positioned against the tooltip anchor. Renders a <div> element.

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-open
data-closed
data-uncentered
data-anchor-hidden
data-side