Overview
The Tooltip component provides contextual information in a floating popup that appears when users hover over (on desktop) or click (on mobile) an element. It supports titles, descriptions, and call-to-action links.Basic Usage
Props
The trigger element that activates the tooltip. Can be:
- Plain text (automatically gets dotted underline)
- React elements (rendered as-is)
- Interactive elements like buttons or links (maintains their interactivity)
The main descriptive text shown in the tooltip popup. Typically contains the helpful information you want to convey.
Optional title shown above the description in the tooltip. Displayed in a bolder, more prominent style.
Call-to-action text for an optional link. Must be used together with
href. Displays with a chevron icon.URL for the call-to-action link. Must be used together with
cta. Remote URLs automatically open in a new tab.Preferred side of the trigger element where the tooltip appears. The tooltip will automatically flip to the opposite side if there’s not enough space.
Alignment of the tooltip relative to the trigger element:
start: Aligns to the start edgecenter: Centers the tooltip (default)end: Aligns to the end edge
Additional CSS classes to apply to the trigger element.
Examples
Simple Tooltip
With Title
With Call-to-Action
Positioning
Alignment
Interactive Children
External Links
Complex Content
In Documentation
Behavior
Desktop (Hover Support)
- Tooltip appears on hover
- Disappears when mouse leaves
- No delay for instant feedback
Mobile (No Hover)
- Tooltip appears on click/tap
- Remains open until:
- User clicks elsewhere (outside press)
- User presses Escape key
- User clicks the trigger again
Text vs Interactive Children
Plain Text:- Automatically styled with dotted underline
- Wrapped in a
<span>for proper tooltip functionality - Gets an
aria-labelcombining title and description
- Rendered without modifications
- Maintains original functionality
- No automatic underline styling
- No
aria-label(interactive elements should have their own labels)
Collision Detection
The tooltip automatically:- Flips to opposite side when near viewport edges
- Maintains 8px padding from viewport edges
- Adjusts position to stay fully visible
Features
Automatic Link Handling
When usingcta with href:
- Remote URLs (starting with
http://orhttps://) automatically:- Open in a new tab (
target="_blank") - Include security attributes (
rel="noreferrer")
- Open in a new tab (
- Internal links open normally
Maximum Width
Tooltips have a maximum width of 16rem (256px) to ensure content remains readable and doesn’t span too wide.Dark Mode
Full dark mode support with:- Adjusted background and border colors
- Proper text contrast
- Smooth transitions between themes
Accessibility
- Proper ARIA labels for non-interactive triggers
- Keyboard navigation support
- Focus visible states with ring indicators
- Escape key closes tooltip
- Outside click detection
Shadow and Styling
Tooltips include:- Subtle shadow for depth
- Rounded corners (12px border radius)
- Proper spacing and padding
- Clean typography hierarchy
Styling
The tooltip popup includes:- White background (dark gray in dark mode)
- Subtle border
- Shadow for elevation
- Proper text hierarchy:
- Title: 12px, medium weight, primary color
- Description: 12px, normal weight, secondary color
- CTA: 12px, medium weight, link color with hover state
Best Practices
Keep tooltip content concise. Long descriptions can be overwhelming. Consider using a CTA link to detailed documentation instead.
Use tooltips for supplementary information, not critical content. Users on mobile need to explicitly tap to see tooltips.
Don’t nest tooltips or use tooltips on disabled elements. These patterns can create confusing user experiences.
Notes
- The component uses
@base-ui/react/tooltipas its foundation - Returns
nullifchildrenis null or undefined - Title and description are optional, but at least one should be provided
- CTA and href must be used together (both or neither)