Anatomy
Usage
To display a tooltip, compose <Tooltip>
, <TooltipTrigger>
, and <TooltipContent>
. It default to displaying centered above the trigger and adjust position to avoid colliding with the edge of the viewport. Pressing esc or clicking away will close the tooltip.
Position
Tooltips can display on every side
of the trigger.
Size
You can display a smaller tooltip by setting the variant
of <TooltipContent>
to "compact"
.
Delay
Use the delayDuration
prop to control the time it takes for the tooltip to open.
API Reference
TooltipProvider
Wraps the app to provide global functionality to tooltips.
Prop | Type | Default |
---|---|---|
delayDuration | number | 700 |
disableHoverableContent | boolean | |
skipDelayDuration | number | 300 |
Tooltip
Contains all the parts of a tooltip.
Prop | Type | Default |
---|---|---|
children | ReactNode | |
defaultOpen | boolean | 300 |
delayDuration | number | 100 |
disableHoverableContent | boolean | |
onOpenChange | (open: boolean) => void | |
open | boolean |
TooltipTrigger
The button that toggles the tooltip. By default, <TooltipContent>
will position itself against the trigger.
Inherits properties from HTMLButtonElement
.
Prop | Type | Default |
---|---|---|
asChild | boolean | true |
TooltipContent
The component that pops out when the tooltip is open.
Inherits properties from HTMLElement
.
Prop | Type | Default |
---|---|---|
align | "start" "center" "end" | "center" |
alignOffset | number | 0 |
aria-label | string | |
asChild | boolean | false |
avoidCollisions | boolean | true |
className | string | |
collisionBoundary | Element null Array<Element | null> | [] |
collisionPadding | number Partial<Record<Side, number>> | 0 |
forceMount | boolean | |
hideWhenDetached | boolean | false |
onEscapeKeyDown | (event: KeyboardEvent) => void | |
onPointerDownOutside | (event: PointerDownOutsideEvent) => void | |
side | "top" "right" "bottom" "left" | "top" |
sideOffset | number | 10 |
sticky | "partial" "always" | "partial" |
variant | "default" "compact" | "default" |