Skip to main content

Tooltip

The Tooltip component displays contextual information when users hover over or focus on an element. It’s useful for providing additional context without cluttering the interface.

Import

Anatomy

The Tooltip component consists of several parts:
  • <Tooltip.Root> - Groups all parts of the tooltip
  • <Tooltip.Trigger> - The element that triggers the tooltip
  • <Tooltip.Positioner> - Positions the tooltip relative to the trigger
  • <Tooltip.Popup> - The tooltip content container
  • <Tooltip.Arrow> - An optional arrow pointing to the trigger
  • <Tooltip.Provider> - Manages shared behavior for multiple tooltips

Basic Usage

Key Features

  • Multiple triggers: Hover, focus, and custom triggers
  • Smart positioning: Automatically positions to stay in viewport
  • Accessible: Proper ARIA attributes and keyboard support
  • Delay control: Customize open and close delays
  • Cursor tracking: Optionally follow the cursor
  • Hoverable content: Keep tooltip open when hovering the popup
  • Portal support: Render tooltip in a different DOM location
  • Animation support: Built-in transition states

Component Props

Root

Groups all parts of the tooltip and manages open state. Props:
  • open (boolean): Controlled open state
  • defaultOpen (boolean): Initially open state (default: false)
  • onOpenChange (function): Callback when open state changes
  • onOpenChangeComplete (function): Callback after animations complete
  • disabled (boolean): Whether the tooltip is disabled (default: false)
  • disableHoverablePopup (boolean): Prevent hovering the popup (default: false)
  • trackCursorAxis (string): Track cursor on ‘x’, ‘y’, ‘both’, or ‘none’ (default: ‘none’)
  • actionsRef (ref): Access to imperative actions (unmount, close)
  • handle (TooltipHandle): Associate with external triggers
  • triggerId (string): ID of the active trigger (controlled mode)
  • defaultTriggerId (string): Initial trigger ID
  • Doesn’t render its own HTML element

Trigger

The element that triggers the tooltip. Props:
  • delay (number): Open delay in milliseconds (default: 600)
  • closeDelay (number): Close delay in milliseconds (default: 0)
  • closeOnClick (boolean): Whether clicking closes the tooltip (default: true)
  • disabled (boolean): Disable this specific trigger (default: false)
  • handle (TooltipHandle): Associate with a tooltip handle
  • payload (any): Data to pass to the tooltip
  • Renders a <button> element

Positioner

Positions the tooltip relative to the trigger. Props:
  • side (string): Preferred side (‘top’, ‘right’, ‘bottom’, ‘left’)
  • align (string): Alignment (‘start’, ‘center’, ‘end’)
  • sideOffset (number): Distance from the trigger
  • alignOffset (number): Offset along the alignment axis
  • collisionBoundary (element): Boundary for collision detection
  • sticky (boolean): Whether to stick to the trigger when scrolling
  • Renders a <div> element
The container for tooltip content. Props:
  • Renders a <div> element
  • Accepts all standard HTML div attributes
State:
  • open: Whether the tooltip is open
  • side: The current side of placement
  • align: The current alignment
  • instant: The animation instant type
  • transitionStatus: Current transition state

Arrow

An optional arrow pointing to the trigger. Props:
  • Renders an <svg> element
  • Automatically positioned and rotated

Provider

Manages shared behavior for multiple tooltips. Props:
  • delay (number): Default delay for all tooltips
  • closeDelay (number): Default close delay for all tooltips

Styling

Common Patterns

Controlled Tooltip

Custom Delay

Follow Cursor

Rich Content

Multiple Tooltips with Provider

Disabled Tooltip

Imperative Control

With Keyboard Shortcut