API Reference
Props mirror Base UI React where applicable, adapted for Svelte 5. Native HTML attributes for the rendered element are also accepted unless noted.
Tooltip.Root
Groups all parts of the tooltip. Doesn't render its own HTML element.
Props
open boolean —
- Name
open- Description
Whether the component is open (controlled).
- Type
boolean | undefined
defaultOpen boolean false
- Name
defaultOpen- Description
Whether the component is initially open (uncontrolled).
- Type
boolean- Default
false
onOpenChange function —
- Name
onOpenChange- Description
Event handler called when the open state changes.
- Type
((open: boolean, eventDetails: { reason: OpenChangeReason }) => void) | undefined
onOpenChangeComplete function —
- Name
onOpenChangeComplete- Description
Event handler called after any animations complete when the tooltip is opened or closed.
- Type
((open: boolean) => void) | undefined
openDelay number 600
- Name
openDelay- Description
How long to wait before opening on hover (ms).
- Type
number- Default
600
closeDelay number —
- Name
closeDelay- Description
—
- Type
number
Data attributes
| Attribute | Description |
|---|---|
data-closed | Present when the part is closed. |
data-open | Present when the part is open. |
Tooltip.Provider
Provides a shared delay for multiple tooltips. The grouping logic ensures that once a tooltip becomes visible, the adjacent tooltips will be shown instantly.
Props
closeDelay number —
- Name
closeDelay- Description
Shared close delay for nested tooltips (ms).
- Type
number
Tooltip.Arrow
Displays an element positioned against the tooltip anchor. Renders a <div> element.
Props
Data attributes
| Attribute | Description |
|---|---|
data-closed | Present when the tooltip is closed. |
data-open | Present when the tooltip is open. |
Tooltip.Popup
A container for the tooltip contents. Renders a <div> element.
Props
Data attributes
| Attribute | Description |
|---|---|
data-closed | Present when the tooltip is closed. |
data-ending-style | Present when the tooltip is animating out. |
data-open | Present when the tooltip is open. |
data-starting-style | Present when the tooltip begins animating in. |
Tooltip.Portal
A portal element that moves the popup to a different part of the DOM. By default, the portal element is appended to <body>. Renders a <div> element.
Props
container HTMLElement | string | null —
- Name
container- Description
A parent element to render the portal element into.
- Type
HTMLElement | string | null
keepMounted boolean false
- Name
keepMounted- Description
Whether to keep the portal mounted in the DOM while the popup is hidden.
- Type
boolean- Default
false
Tooltip.Positioner
Positions the tooltip against the trigger. Renders a <div> element.
Props
side voi 'top'
- Name
side- Description
Which side of the anchor element to align the popup against. May automatically change to avoid collisions.
- Type
voi- Default
'top'
align penIn 'center'
- Name
align- Description
How to align the popup relative to the specified side.
- Type
penIn- Default
'center'
sideOffset an; }; 0
- Name
sideOffset- Description
Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side.- Type
an; };- Default
0
alignOffset ltipCo 0
- Name
alignOffset- Description
Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side.- Type
ltipCo- Default
0
collisionPadding boolean 5
- Name
collisionPadding- Description
Additional space to maintain from the edge of the collision boundary.
- Type
en: boolean; setOpen(open: boolean, r- Default
5
collisionBoundary ): void; openW 'clipping-ancestors'
- Name
collisionBoundary- Description
An element or a rectangle that delimits the area that the popup is confined to.
- Type
): void; openW- Default
'clipping-ancestors'
collisionAvoidance ngeReason): void; —
- Name
collisionAvoidance- Description
- Determines how to handle collisions when positioning the popup.
sidecontrols overflow on the preferred placement axis (top/bottomorleft/right):'flip': keep the requested side when it fits; otherwise try the opposite side - (
topandbottom, orleftandright). 'shift': never change side; keep the requested side and move the popup within the clipping boundary so it stays visible.'none': do not correct side-axis overflow.aligncontrols overflow on the alignment axis (start/center/end):'flip': keep side, but swapstartandendwhen the requested alignment overflows.'shift': keep side and requested alignment, then nudge the popup along the alignment axis to fit.'none': do not correct alignment-axis overflow.fallbackAxisSidecontrols fallback behavior on the perpendicular axis when the preferred axis cannot fit:'start': allow perpendicular fallback and try the logical start side first- (
topbeforebottom, orleftbeforerightin LTR). 'end': allow perpendicular fallback and try the logical end side first- (
bottombeforetop, orrightbeforeleftin LTR). 'none': do not fallback to the perpendicular axis. Whensideis'shift', explicitly settingalignonly supports'shift'or'none'.- If
alignis omitted, it defaults to'flip'.
- Determines how to handle collisions when positioning the popup.
- Type
ngeReason): void;
arrowPadding ason: 5
- Name
arrowPadding- Description
Minimum distance to maintain between the arrow and the edges of the popup. Use it to prevent the arrow element from hanging out of the rounded corners of a popup.
- Type
ason:- Default
5
sticky ason): false
- Name
sticky- Description
Whether to maintain the popup in the viewport after the anchor element was scrolled out of view.
- Type
ason):- Default
false
positionMethod g; readonly refs: 'absolute'
- Name
positionMethod- Description
Maps to Floating UI strategy (
absolute|fixed).- Type
g; readonly refs:- Default
'absolute'
anchor /** Shared open delay for… —
- Name
anchor- Description
Override the positioning anchor (element or virtual element).
- Type
/** Shared open delay for neste
disableAnchorTracking (ms). false
- Description
When
true, skip continuous layout tracking of the anchor (position once; no resize/scroll auto-updates beyond the initial compute).- Type
(ms).- Default
false
Data attributes
| Attribute | Description |
|---|---|
data-closed | Present when the tooltip is closed. |
data-open | Present when the tooltip is open. |
data-side | Indicates which side the popup is positioned relative to the trigger. |
Tooltip.Trigger
An element to attach the tooltip to. Renders a <button> element.
Props
render string —
- Name
render- Description
HTML element tag to render instead of the default host element.
- Type
string
disabled boolean false
- Name
disabled- Description
Whether the control ignores user interaction.
- Type
boolean- Default
false
handle TooltipHandle —
- Name
handle- Description
Same handle as Root — enables triggers outside the Root tree.
- Type
TooltipHandle | undefined
Data attributes
| Attribute | Description |
|---|---|
data-closed | Present when the part is closed. |
data-disabled | Present when the part is disabled. |
data-open | Present when the part is open. |
Tooltip.Viewport
A viewport for displaying content transitions. This component is only required if one popup can be opened by multiple triggers, its content changes based on the trigger, and switching between them is animated. Renders a <div> element.
Props
Data attributes
| Attribute | Description |
|---|---|
data-closed | Present when the part is closed. |
data-open | Present when the part is open. |