Installation
Setup
Add theTooltipProvider to the root of your app:
app/layout.tsx
Usage
Examples
Basic
A simple tooltip with text content.Positioning
Control the position of the tooltip using theside prop.
With Arrow
Tooltips include an arrow by default pointing to the trigger element.Keyboard Shortcut
Display keyboard shortcuts in tooltips.Disabled Button
Show a tooltip on a disabled button by wrapping it with a span.Delay Duration
Control how long the user must hover before the tooltip appears.Rich Content
Tooltips can contain rich content, not just text.Component Code
Props
TooltipProvider
| Prop | Type | Default | Description |
|---|---|---|---|
delayDuration | number | 0 | Time in ms before tooltip appears |
skipDelayDuration | number | 300 | Time before delay resets after pointer leaves |
disableHoverableContent | boolean | false | Prevents hovering over tooltip content |
Tooltip
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | - | Controlled open state |
defaultOpen | boolean | false | Default open state (uncontrolled) |
onOpenChange | (open: boolean) => void | - | Callback when open state changes |
delayDuration | number | - | Overrides provider’s delayDuration |
TooltipTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Merge props with child element |
className | string | - | Additional CSS classes |
TooltipContent
| Prop | Type | Default | Description |
|---|---|---|---|
side | "top" | "right" | "bottom" | "left" | "top" | Preferred side of the trigger |
sideOffset | number | 0 | Distance from trigger in pixels |
align | "start" | "center" | "end" | "center" | Alignment relative to trigger |
alignOffset | number | 0 | Offset from alignment position |
className | string | - | Additional CSS classes |
Accessibility
- Automatically associates tooltip with trigger using
aria-describedby - Keyboard accessible (opens on focus, closes on blur/escape)
- Uses
role="tooltip"for screen readers - Portal rendering prevents z-index issues
- Respects
prefers-reduced-motion
Best Practices
- Keep tooltip text concise and informative
- Don’t use tooltips for critical information
- Ensure tooltips don’t hide important content
- Use
asChildon trigger to merge with custom components - Wrap disabled buttons in a span to enable tooltips
- Consider using instant tooltips (
delayDuration={0}) for frequently accessed items