shadcn.io is an independent project built on shadcn/ui
On this page9 sections
A tooltip is a short label that appears beside a control on hover or keyboard focus and goes away when the pointer or focus moves on. Reach for it when a control doesn't say what it does, such as an icon-only button in a toolbar, or to show the keyboard shortcut behind it.
When people need to move into the content or read more than a line, use a Hover Card. Anything they have to click belongs in a Popover.
Installation
Anatomy

Usage
import { Button } from "@/components/ui/button";
import {
Tooltip, TooltipContent, TooltipTrigger,
} from "@/components/ui/tooltip";<Tooltip>
<TooltipTrigger asChild>
<Button variant="outline">Hover</Button>
</TooltipTrigger>
<TooltipContent>
<p>Add to library</p>
</TooltipContent>
</Tooltip>Accessibility
The tooltip has role="tooltip", and while it's open the trigger's aria-describedby points at it, so a screen reader reads its text after the trigger's own name. Keyboard focus opens it at once and Escape closes it. The tooltip only describes the trigger, so an icon-only button still needs a name of its own, such as an aria-label.
- Tab
- Opens/closes the tooltip without delay.
- EscEscape
- If open, closes the tooltip without delay.
- Enter
- When focus is on the trigger, activates it and closes the tooltip.
- Space
- When focus is on the trigger, activates it and closes the tooltip.
Demos
Sides
Four buttons, left, top, bottom and right, each show Add to library on that side. placement in the positioning prop on Tooltip picks it, and this file defaults to top. Pin a side when the default would cover what someone is working on, such as the first row of a table under a toolbar. When there isn't room, the tooltip flips to the opposite side.
Keyboard
An icon-only save button whose aria-label is Save Changes, with a tooltip that repeats the name beside an S in a Kbd. Use this to advertise a shortcut on a toolbar button. The Kbd is only text, so register the key handler yourself.
Disabled
The disabled button sits inside a span that acts as the trigger, because this registry's Button turns off pointer events while disabled. The span has role="button", aria-disabled and a place in the tab order, so hovering it or tabbing to it shows This feature is currently unavailable. A screen reader announces a disabled button with that reason as its description.
RTL
Add to library in Arabic, inside a Direction provider set to right to left, which also turns the tooltip's own text right to left. The first row picks physical sides, which stay put whatever the language. Ark UI only takes physical sides, so the second row maps the start of the line to right and its end to left itself.
FAQ
How do I change the Tooltip delay in React?
Set openDelay and closeDelay on one Tooltip, or delay and closeDelay on a TooltipProvider around a group. Without either, this file opens at once and closes after 100 milliseconds, where Ark UI's own defaults are 400 and 150.
A short delay suits a toolbar people scan with the pointer. A longer one keeps tooltips from flashing over a dense table as the pointer crosses it.
Do I need a TooltipProvider with Ark UI?
No. TooltipProvider in this file is a small context of its own that hands its delay and closeDelay to the tooltips inside it, and nothing else. Ark UI already opens a tooltip at once when another one is showing.
How do I change which side the Tooltip appears on?
Pass positioning to Tooltip with a placement such as bottom or right-start. This file merges yours over its own placement of top and gutter of 4, so setting one keeps the other. Ark UI adds half the arrow's size to the gutter, which puts the tooltip 7 pixels from its trigger.
The Sides demo shows all four. When there isn't room on the side you picked, the tooltip flips to the opposite one.
Why doesn't my Tooltip show on a disabled button?
A disabled button can't take focus, and this registry's Button turns off pointer events while it's disabled, so neither hover nor focus reaches it. Wrap the button in a span and make the span the trigger, as the Disabled demo does.
Give that span role="button", aria-disabled set to true and a place in the tab order. Keyboard users then reach it too, and a screen reader announces a disabled button with the tooltip's text as its description.
Does a screen reader read the Tooltip text?
Yes, while it's open. Ark UI gives the tooltip role="tooltip" and points the trigger's aria-describedby at it, so the text is read as a description after the trigger's name. It only opens on keyboard focus or hover, so put anything essential in the trigger's own label as well.
Can I put a link or a button inside a Tooltip?
Not one that everyone can use. The tooltip closes as soon as focus leaves its trigger, so Tab never reaches a link inside it, and a click on the trigger closes it too. On Ark UI the pointer can't reach it either: the content ignores the mouse and closes as the pointer leaves the trigger, unless you set interactive on Tooltip.
Use a Popover when the extra content holds a link or a button, or a Hover Card for a preview the pointer can move into. Keep a tooltip to a few words of plain text, with at most a shortcut as in the Keyboard demo.
How do I keep a Tooltip open, or open it from code?
Pass open on Tooltip and update your state in onOpenChange, which receives an object with the next state in open. Setting defaultOpen instead opens it on the first render and leaves it uncontrolled.
Holding it open without a callback is the quickest way to style a tooltip without chasing it with the pointer. A product tour can also open one to point at a control.
Does the Tooltip work on mobile and touch screens?
Not as a hover hint. Touch screens have no hover, and Ark UI ignores touch pointers when it decides to open a tooltip, so a tap only activates the trigger.
Anything a phone user needs has to be in the trigger's label or on the page. For a hint people open on purpose with a tap, use a Toggle Tooltip.
API Reference
Tooltip
data-slot="tooltip"
open?boolean
The controlled open state of the tooltip.
defaultOpen?boolean
The initial open state of the tooltip when rendered. Use when you don't need to control the open state of the tooltip.
onOpenChange?(details: OpenChangeDetails) → void
Function called when the tooltip is opened.
- Type
(details: OpenChangeDetails) → void- Parameters
details– { open: boolean }- Returns
void
triggerValue?string | null
The controlled trigger value.
- Type
string | null
defaultTriggerValue?string | null
The initial trigger value when rendered. Use when you don't need to control the trigger value.
- Type
string | null
onTriggerValueChange?(details: TriggerValueChangeDetails) → void
Function called when the trigger value changes.
- Type
(details: TriggerValueChangeDetails) → void- Parameters
details– { value: string | null; triggerElement: HTMLElement | null }- Returns
void
closeDelay?number
The close delay of the tooltip. Ark default: 150.
- Default
provider.closeDelay
closeOnClick?boolean
Whether the tooltip should close on click.
- Default
true
closeOnEscape?boolean
Whether to close the tooltip when the Escape key is pressed.
- Default
true
closeOnPointerDown?boolean
Whether to close the tooltip on pointerdown.
- Default
true
closeOnScroll?boolean
Whether the tooltip should close on scroll.
- Default
true
dir?"ltr" | "rtl"
The document's text/writing direction.
- Type
"ltr" | "rtl"- Default
"ltr"
disabled?boolean
Whether the tooltip is disabled.
hideMode?"display-none" | "activity"
How to hide content when mounted but not present.
- display-none: HTML hidden attribute. Effects stay alive.
- activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.
- Type
"display-none" | "activity"- Default
"display-none"
id?string
The unique identifier of the machine.
ids?object
The ids of the elements in the tooltip. Useful for composition.
- Type
{ trigger?: string | ((value?: string) → string); content?: string; arrow?: string; positioner?: string }
immediate?boolean
Whether to synchronize the present change immediately or defer it to the next frame.
interactive?boolean
Whether the tooltip's content is interactive. In this mode, the tooltip will remain open when user hovers over the content.
- Default
false
lazyMount?boolean
Whether to enable lazy mounting. Ark default: false.
- Default
true
onEnterComplete?VoidFunction
Function called when the animation ends in the open state.
onExitComplete?VoidFunction
Function called when the animation ends in the closed state.
openDelay?number
The open delay of the tooltip. Ark default: 400.
- Default
provider.openDelay
positioning?object
The user provided options used to position the popover content.
- Type
{ restoreStyles?: boolean; applyStyles?: boolean; hideWhenDetached?: boolean; strategy?: "absolute" | "fixed"; placement?: Placement; offset?: { mainAxis?: number; crossAxis?: number; }; gutter?: number; shift?: number; overflowPadding?: number; arrowPadding?: number; flip?: boolean | Placement[]; slide?: boolean; overlap?: boolean; sameWidth?: boolean; fitViewport?: boolean; sizeMiddleware?: boolean; boundary?: (() → Boundary) | Boundary | "clipping-ancestors"; listeners?: boolean | AutoUpdateOptions; onComplete?: (data: ComputePositionReturn) → void; onPositioned?: ((data: { placed: boolean; }) → void); getAnchorElement?: () → HTMLElement | VirtualElement | null; getAnchorRect?: (element: HTMLElement | VirtualElement | null) → AnchorRect | null; updatePosition?: ((data: { updatePosition: () → Promise<void>; floatingElement: HTMLElement | null; }) → void | Promise<void>) }
present?boolean
Whether the node is present (controlled by the user).
skipAnimationOnMount?boolean
Whether to allow the initial presence animation.
- Default
false
unmountOnExit?boolean
Whether to unmount on exit. Ark default: false.
- Default
true
TooltipTrigger
<button> data-slot="tooltip-trigger"
value?string
The value that identifies this specific trigger.
asChild?boolean
Use the provided child element as the default rendered element, combining their props and behavior.
data-current?string
Present when current.
data-expanded?string
Present when expanded.
data-state"open" | "closed"
"open" or "closed".
- Type
"open" | "closed"
data-value?string
The value of the item.
TooltipArrow
<div> data-slot="tooltip-arrow"
asChild?boolean
Use the provided child element as the default rendered element, combining their props and behavior.
className?string
Merged with the part's classes.
--arrow-backgroundstring
Use this variable to style the arrow background.
--arrow-offsetstring
The offset position of the arrow.
--arrow-sizestring
The size of the arrow.
--arrow-size-halfstring
Half the size of the arrow.
TooltipArrowTip
<div>
asChild?boolean
Use the provided child element as the default rendered element, combining their props and behavior.
TooltipPositioner
<div> data-slot="tooltip-positioner"
asChild?boolean
Use the provided child element as the default rendered element, combining their props and behavior.
--available-heightstring
The available height in viewport.
--available-widthstring
The available width in viewport.
--reference-heightstring
The height of the root.
--reference-widthstring
The width of the reference element.
--transform-originstring
The transform origin for animations.
--xstring
The x position for transform.
--ystring
The y position for transform.
--z-indexstring
The z-index value.
TooltipContent
<div> data-slot="tooltip-content"
asChild?boolean
Use the provided child element as the default rendered element, combining their props and behavior.
className?string
Merged with the part's classes.
data-instant?string
Present when instant is true.
data-placementstring
The placement of the content.
data-side"top" | "right" | "bottom" | "left"
The side of the trigger that the content is positioned on.
- Type
"top" | "right" | "bottom" | "left"
data-state"open" | "closed"
"open" or "closed".
- Type
"open" | "closed"
--transform-originstring
Where the content scales from, on its trigger's side.
TooltipProvider
closeDelay?number
Close delay in ms. Maps to Ark closeDelay on nested tooltips.
- Default
100
delay?number
Open delay in ms. Maps to Ark openDelay / Base UI delay.
- Default
0
useTooltip
open?boolean
The controlled open state of the tooltip.
defaultOpen?boolean
The initial open state of the tooltip when rendered. Use when you don't need to control the open state of the tooltip.
onOpenChange?(details: OpenChangeDetails) → void
Function called when the tooltip is opened.
- Type
(details: OpenChangeDetails) → void- Parameters
details– { open: boolean }- Returns
void
triggerValue?string | null
The controlled trigger value.
- Type
string | null
defaultTriggerValue?string | null
The initial trigger value when rendered. Use when you don't need to control the trigger value.
- Type
string | null
onTriggerValueChange?(details: TriggerValueChangeDetails) → void
Function called when the trigger value changes.
- Type
(details: TriggerValueChangeDetails) → void- Parameters
details– { value: string | null; triggerElement: HTMLElement | null }- Returns
void
closeDelay?number
The close delay of the tooltip.
- Default
150
closeOnClick?boolean
Whether the tooltip should close on click.
- Default
true
closeOnEscape?boolean
Whether to close the tooltip when the Escape key is pressed.
- Default
true
closeOnPointerDown?boolean
Whether to close the tooltip on pointerdown.
- Default
true
closeOnScroll?boolean
Whether the tooltip should close on scroll.
- Default
true
disabled?boolean
Whether the tooltip is disabled.
id?string
The unique identifier of the machine.
ids?object
The ids of the elements in the tooltip. Useful for composition.
- Type
{ trigger?: string | ((value?: string) → string); content?: string; arrow?: string; positioner?: string }
interactive?boolean
Whether the tooltip's content is interactive. In this mode, the tooltip will remain open when user hovers over the content.
- Default
false
openDelay?number
The open delay of the tooltip.
- Default
400
positioning?object
The user provided options used to position the popover content.
- Type
{ restoreStyles?: boolean; applyStyles?: boolean; hideWhenDetached?: boolean; strategy?: "absolute" | "fixed"; placement?: Placement; offset?: { mainAxis?: number; crossAxis?: number; }; gutter?: number; shift?: number; overflowPadding?: number; arrowPadding?: number; flip?: boolean | Placement[]; slide?: boolean; overlap?: boolean; sameWidth?: boolean; fitViewport?: boolean; sizeMiddleware?: boolean; boundary?: (() → Boundary) | Boundary | "clipping-ancestors"; listeners?: boolean | AutoUpdateOptions; onComplete?: (data: ComputePositionReturn) → void; onPositioned?: ((data: { placed: boolean; }) → void); getAnchorElement?: () → HTMLElement | VirtualElement | null; getAnchorRect?: (element: HTMLElement | VirtualElement | null) → AnchorRect | null; updatePosition?: ((data: { updatePosition: () → Promise<void>; floatingElement: HTMLElement | null; }) → void | Promise<void>) }











