Skip to content

Tooltip

A visual hint that labels a control on hover or keyboard focus.

hero.tsx

Usage guidelines

  • Use Tooltip for 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, use Infotip.
  • Tooltip content is not the trigger's accessible name. An icon-only trigger such as IconButton keeps its own aria-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 Popover or an Infotip.
  • Text length alone does not decide between Tooltip and Infotip. Decide by what the trigger does and whether the content must be reachable.
  • TooltipProvider shares 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 composes Tooltip without adding its own.
  • Compose the trigger through render so the control keeps its own component, such as IconButton or Button.

Anatomy

tsx
tsx

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.

shortcut.tsx

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.

text-trigger.tsx

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.

disabled-trigger.tsx

Keyboard

KeyAction
TabMoves focus to the trigger and opens its tooltip.
EscapeCloses 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.

Base UI Tooltip.Root docs

TooltipContent

A styled tooltip popup bundled with a portal and positioner. Renders a <div> element.

Base UI Tooltip.Popup docs

Props
PropTypeDefaultDetails
sideOffsetnumber | OffsetFunction8
children requiredReact.ReactNodeNo default
Base UI Tooltip.Popup docs
Data attributes
AttributeDescription
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: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'

Indicates which side the popup is positioned relative to the trigger.

data-align

Values: 'start' | 'center' | 'end'

Indicates how the popup is aligned relative to specified side.

data-instant

Values: 'delay' | 'dismiss' | 'focus'

Present if animations should be instant.

CSS variables
VariableDescription
--available-width

Values: number

The available width between the trigger and the edge of the viewport.

--available-height

Values: number

The available height between the trigger and the edge of the viewport.

--anchor-width

Values: number

The anchor's width.

--anchor-height

Values: number

The anchor's height.

--transform-origin

Values: string

The coordinates that this element is anchored to. Used for animations and transitions.

--positioner-width

Values: number

The width of the tooltip's positioner. It is important to set width to this value when using CSS to animate size changes.

--positioner-height

Values: number

The height of the tooltip's positioner. It is important to set height to this value when using CSS to animate size changes.

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.

Base UI Tooltip.Provider docs

TooltipTrigger

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

Base UI Tooltip.Trigger docs

Data attributes
AttributeDescription
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.