Skip to content

useTooltip

@astryxdesign/core v0.7.1 · useTooltip

Parameters ​

NameTypeDefaultDescription
placement'above' | 'below' | 'start' | 'end' | MaybeRefOrGetter'above'Position relative to the trigger. Logical: start / end mirror under RTL. Flips when there is no room.
alignment'start' | 'center' | 'end' | MaybeRefOrGetter'center'Alignment along the placement axis.
delaynumber | MaybeRefOrGetter200Delay before showing on hover, in milliseconds.
hideDelaynumber | MaybeRefOrGetter0Delay before hiding after the pointer or focus leaves, in milliseconds. 0 uses the internal 100 ms bridge instead.
focusTrigger'auto' | 'always' | 'never' | MaybeRefOrGetter'auto'When focus opens the tooltip. auto only attaches focus listeners to naturally focusable elements.
touchTrigger'auto' | 'tap' | 'none' | MaybeRefOrGetter'auto'What a tap does where there is no hover. auto opens on tap unless the trigger performs an action of its own; tap always opens; none never opens on touch.
isEnabledboolean | MaybeRefOrGettertrueWhether hover and focus triggers are enabled.
isOpenboolean | undefined | MaybeRefOrGetter—Controlled open state. true force-shows, false force-hides, undefined lets hover and focus manage visibility.
isDefaultOpenbooleanfalseWhether the tooltip is shown on mount.
onShow() => void—Called when the tooltip becomes visible.
onHide() => void—Called when the tooltip is hidden.

Returns ​

FieldTypeDescription
isOpenComputedRef<boolean>Whether the tooltip is showing. A controlled isOpen wins over the hover state.
triggerRefRef<HTMLElement | null>Trigger element. Bind it with :ref; the hook attaches the handlers and the ARIA link.
contentRefRef<HTMLElement | null>Bubble container.
idstringUnique ID of the bubble.
anchorIdstringCSS identifier for the anchor element, for advanced positioning cases.
describedBystringID to compose into aria-describedby. The hook already writes it onto triggerRef; it is here for hand-written ARIA.
contentStyleComputedRef<CSSProperties>Inline coordinates for the bubble.
resolvedPlacementComputedRef<'above' | 'below' | 'start' | 'end'>Placement actually in effect, after flipping for available space.
contentPropsComputedRef<Record<string, unknown>>Attributes for the bubble: id, role="tooltip", and the pointer handlers that keep it open.