Tooltip

Overlays

A short label shown when its trigger is hovered or focused with the keyboard, and announced as the trigger's description. Escape hides it. Put one Tooltip.Provider around the app; each tooltip is a <Tooltip.Root> with a Tooltip.Trigger and a Tooltip.Content.

import { Tooltip } from '@limerdev/zest';
Tooltip for AI tools (llms.txt)
Use for
Naming an icon-only button, or a brief hint about a control.
Don't
Information the user needs and can't get otherwise: touch screens can't hover. Links or buttons inside a tooltip: use Popover. A tooltip as an icon button's only name: give the button aria-label too.

Examples

Icon buttons

Tooltips name icon-only buttons; each button still has its own aria-label. Put one Tooltip.Provider around the app.

Sides

side places the tooltip; it flips when there is no room.

Props

Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that renders your own element, with props to spread on it).

Tooltip.Root

Prop Type Default Description
delayDuration number 700 The delay in milliseconds before the tooltip opens.
disableCloseOnTriggerClick boolean false When true, the tooltip will not close when you click on the trigger.
disabled boolean false When true, the tooltip will be disabled and will not open.
disableHoverableContent boolean false Prevents tooltip from remaining open when hovering over the content.
ignoreNonKeyboardFocus boolean false Prevent the tooltip from opening if the focus did not come using the keyboard.
onOpenChange OnChangeFn<boolean> – A callback that will be called when the tooltip is opened or closed.
onOpenChangeComplete OnChangeFn<boolean> – A callback that will be called when the tooltip is opened or closed.
open bindable boolean false The open state of the tooltip.
tether TooltipTether<never> – Shared tether used to connect detached triggers and infer payload types.
triggerId string | null – The active trigger id for controlled single tooltip mode.

Tooltip.Provider

Prop Type Default Description
delayDuration number 400 The delay in milliseconds before the tooltip opens.
disableCloseOnTriggerClick boolean false When true, the tooltip will not close when you click on the trigger.
disabled boolean false When true, the tooltip will be disabled and will not open.
disableHoverableContent boolean false Prevents tooltip from remaining open when hovering over the content.
ignoreNonKeyboardFocus boolean false Prevent the tooltip from opening if the focus did not come using the keyboard.
skipDelayDuration number 300 How much time a user has to enter another trigger without incurring a delay again.

Tooltip.Trigger

Prop Type Default Description
disabled null | false | true false Whether the tooltip trigger is disabled or not.
payload unknown – Payload for the trigger used by singleton tooltip root snippets.
size "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" 'default' The height and padding, from the theme's field size; the icon sizes are square.
tether TooltipTether<never> – Shared tether used to connect detached triggers and infer payload types.
variant "link" | "primary" | "secondary" | "neutral" | "error" | "outline" | "ghost" 'primary' The look, by the theme's colour roles: primary for the main action, error for deleting, secondary, neutral and outline for the rest, ghost in toolbars, link for a navigation that looks like text.

Tooltip.Content

Prop Type Default Description
align "start" | "center" | "end" – The preferred alignment of the anchor to render against when open. This may change when collisions occur.
alignOffset number – An offset in pixels from the "start" or "end" alignment options.
arrowPadding number – This describes the padding between the arrow and the edges of the floating element. If your floating element has border-radius, this will prevent it from overflowing the corners.
avoidCollisions boolean true When true, overrides the side and align options to prevent collisions with the boundary edges.
collisionBoundary Arrayable<Boundary> – A boundary element or array of elements to check for collisions against.
collisionPadding number | Partial<Record<"top" | "right" | "bottom" | "left", number>> 8 The amount in pixels of virtual padding around the viewport edges to check for overflow which will cause a collision.
customAnchor string | HTMLElement | Measurable | null – Use an element other than the trigger to anchor the content to. If provided, the content will be anchored to the provided element instead of the trigger. You can pass a selector string or an HTMLElement.
dir "ltr" | "rtl" – The text direction of the content.
escapeKeydownBehavior "close" | "defer-otherwise-close" | "defer-otherwise-ignore" | "ignore" close Escape behavior type. close: Closes the element immediately. defer-otherwise-close: Delegates the action to its parent component that has an escape keydown handler. If no parent is found, it closes the element. defer-otherwise-ignore: Delegates the action to the parent element. If no parent is found, nothing is done. ignore: Prevents the element from closing and also blocks the parent element from closing in response to an escape key press.
forceMount boolean – When true, the tooltip will be forced to mount in the DOM. Useful for more control over the transition behavior.
hideWhenDetached boolean –
interactOutsideBehavior "close" | "defer-otherwise-close" | "defer-otherwise-ignore" | "ignore" close Interact outside behavior type. close: Closes the element immediately. defer-otherwise-close: Delegates the action to the parent element. If no parent is found, it closes the element. defer-otherwise-ignore: Delegates the action to the parent element. If no parent is found, nothing is done. ignore: Prevents the element from closing and also blocks the parent element from closing in response to an outside interaction.
onEscapeKeydown ((e: KeyboardEvent) => void) – Callback fired when escape is pressed.
onFocusOutside ((event: FocusEvent) => void) – Callback fired when focus leaves the dismissible layer.
onInteractOutside InteractOutsideEventHandler – Callback fired when an outside interaction event completes, which is either a pointerup, mouseup, or touchend event, depending on the user's input device.
portalProps PortalProps – Props for the portal the content renders in: to (the element to render in, the body by default) and disabled (render in place).
side "top" | "right" | "bottom" | "left" 'top' The preferred side of the anchor to render against when open. Will be reversed when collisions occur.
sideOffset number 6 The distance in pixels from the anchor to the floating element.
sticky "partial" | "always" –
strategy "absolute" | "fixed" – The positioning strategy to use for the floating element.
updatePositionStrategy "always" | "optimized" "optimized" "optimized" will only update the position when necessary, while "always" will update the position on each animation frame, which is useful if the floating content is following something like a mouse cursor.

Tooltip.Portal

Prop Type Default Description
disabled boolean false Disable portalling and render the component inline
to PortalTarget document.body Where to portal the content to.