Tooltip API
View componentThe full prop reference for the Tooltip component. A popup that displays information related to an element when it receives keyboard focus or hover.
Import
import { Tooltip } from '@structyl/styled';Props
Tooltip.Provider
Context provider that manages shared tooltip timing and delay behavior for all nested tooltips
| Prop | Type | Default |
|---|---|---|
| children# | React.ReactNodeContent to be wrapped by the provider | — |
| delayDuration# | numberDelay in milliseconds before the tooltip opens on hover | 700 |
| skipDelayDuration# | numberDuration in milliseconds after closing before the delay applies again to the next tooltip | 300 |
| disableHoverableContent# | booleanWhen true, disables the ability to hover over tooltip content to keep it open | false |
Tooltip.Root
Root state container for a tooltip instance; manages open/closed state and positioning context
| Prop | Type | Default |
|---|---|---|
| children# | React.ReactNodeTrigger and Content components | — |
| open# | booleanControlled open state; when provided, component becomes controlled | — |
| defaultOpen# | booleanInitial open state when uncontrolled | false |
| onOpenChange# | (open: boolean) => voidCallback fired when tooltip open state changes | — |
| delayDuration# | numberOverride the Provider's delayDuration for this tooltip instance | — |
| disableHoverableContent# | booleanOverride the Provider's disableHoverableContent for this tooltip instance | — |
Tooltip.Trigger
Button element that triggers tooltip visibility on hover, focus, or click
| Prop | Type | Default |
|---|---|---|
| asChild# | booleanWhen true, render as the child element instead of a button wrapper | — |
| ...buttonProps# | React.ComponentPropsWithoutRef<'button'>All standard HTML button attributes (onClick, className, disabled, etc.) | — |
Tooltip.Portal
Renders tooltip content into a portal (typically the DOM root) to avoid stacking context issues
| Prop | Type | Default |
|---|---|---|
| children# | React.ReactNodeTooltip Content component | — |
| container# | Element | DocumentFragment | nullDOM element to portal content into; defaults to document.body | — |
| forceMount# | booleanWhen true, Content is mounted to the DOM regardless of open state | — |
Tooltip.Content
Container for tooltip message; handles positioning, visibility, and floating-ui integration (primitive version)
| Prop | Type | Default |
|---|---|---|
| asChild# | booleanWhen true, render as the child element instead of a div wrapper | — |
| forceMount# | booleanWhen true, Content is mounted to the DOM regardless of open state | — |
| side# | 'top' | 'right' | 'bottom' | 'left'Preferred position relative to the trigger | 'top' |
| sideOffset# | numberDistance in pixels between trigger and tooltip content | — |
| align# | 'start' | 'center' | 'end'Alignment of content relative to trigger along the side axis | — |
| alignOffset# | numberOffset in pixels along the align axis | — |
| arrowPadding# | numberDistance in pixels to keep arrow from edge of content | — |
| avoidCollisions# | booleanWhen true, adjust position to avoid viewport collisions | — |
| collisionPadding# | numberDistance in pixels to keep content from viewport edge | — |
| onEscapeKeyDown# | (event: KeyboardEvent) => voidCallback fired when Escape key is pressed on content | — |
| onPointerDownOutside# | (event: PointerEvent) => voidCallback fired when pointer down occurs outside content | — |
| ...divProps# | React.ComponentPropsWithoutRef<'div'>All standard HTML div attributes (className, style, etc.) | — |
Tooltip.Arrow
SVG arrow that points from tooltip content toward the trigger
| Prop | Type | Default |
|---|---|---|
| width# | numberSVG arrow width in pixels | — |
| height# | numberSVG arrow height in pixels | — |
| ...svgProps# | React.ComponentPropsWithoutRef<'svg'>All standard SVG attributes (className, style, etc.) | — |
Tooltip.Content (styled)
Enhanced tooltip content with styling variants and convenience props; wraps the primitive
| Prop | Type | Default |
|---|---|---|
| variant# | 'default' | 'dark' | 'light' | 'primary' | 'secondary' | 'info' | 'warning' | 'error' | 'success'Visual style variant | 'default' |
| maxWidth# | string | numberMaximum width of content in pixels or any CSS value | 280 |
| arrow# | booleanWhen true, renders an arrow pointing to the trigger | false |
| className# | stringAdditional CSS class names, merged with variant styles | — |
| sideOffset# | numberDistance between trigger and content in pixels | 6 |
| ...contentProps# | React.ComponentPropsWithoutRef<TooltipPrimitive.Content>All primitive content props (side, align, forceMount, etc.) and standard div attributes | — |
Tooltip (shorthand)
Convenience component that combines Provider, Root, Trigger, and Content into a single configurable element
| Prop | Type | Default |
|---|---|---|
| children# | React.ReactNodeElement to trigger the tooltip on hover/focus | — |
| label# | React.ReactNodeText or content to display inside the tooltip | — |
| side# | 'top' | 'right' | 'bottom' | 'left'Position of tooltip relative to trigger | 'top' |
| align# | 'start' | 'center' | 'end'Alignment of tooltip along the side axis | — |
| variant# | 'default' | 'dark' | 'light' | 'primary' | 'secondary' | 'info' | 'warning' | 'error' | 'success'Visual style variant | — |
| maxWidth# | string | numberMaximum width of tooltip content | 280 |
| arrow# | booleanWhether to show an arrow pointing to the trigger | false |
| disabled# | booleanWhen true, tooltip is disabled and children render unwrapped | — |
| delayDuration# | numberDelay in milliseconds before tooltip opens | — |
| skipDelayDuration# | numberDuration before delay resets after closing | — |
| ...triggerProps# | React.ComponentPropsWithoutRef<Trigger>All button trigger props (className, onClick, etc.) | — |
Keyboard interactions
| Key | Description |
|---|---|
| Esc | Closes the tooltip. |
Source code
If you didn't find what you need here, read the component implementation .