overlayscss

Tooltip

Singleton text hint shown on hover or keyboard focus of any data-tooltip element, positioned with Floating UI.

CSS Variables

VariableDefaultScopeDescription
--z-tooltip-bgvar(--z-primary).z-tooltipBackground base color, mixed with transparency using --z-tooltip-bg-o.
--z-tooltip-bg-o100%.z-tooltipBackground opacity percentage used in the background color mix.
--z-tooltip-blurvar(--z-global-blur).z-tooltipBackdrop blur radius used by .z-tooltip-blur.
--z-tooltip-colorvar(--z-primary-f).z-tooltipText base color, mixed with transparency using --z-tooltip-color-o.
--z-tooltip-color-o100%.z-tooltipText opacity percentage used in the text color mix.
--z-tooltip-font-size0.75rem.z-tooltipFont size of the tooltip text.
--z-tooltip-line-height1rem.z-tooltipLine height of the tooltip text.
--z-tooltip-max-width208px.z-tooltipMaximum width of the tooltip box; text wraps at this width.
--z-tooltip-padding0.375rem 0.75rem.z-tooltipInner padding of the tooltip box.
--z-tooltip-radiusvar(--z-global-radius).z-tooltipCorner radius of the tooltip box.
--z-tooltip-shadowvar(--z-global-shadow-small).z-tooltipBox shadow of the tooltip box.
--z-tooltip-slide-x0.z-tooltip[data-side='top']Horizontal enter-slide offset for the current side, used by the z-tooltip-in keyframes.
--z-tooltip-slide-y4px.z-tooltip[data-side='top']Vertical enter-slide offset for the current side, used by the z-tooltip-in keyframes.
--z-tooltip-z-index1030.z-tooltipStacking order of the tooltip element.

Events

EventDetailFlagsDescription
z-tooltip:hide{ trigger: HTMLElement; tooltip: HTMLDivElement }bubblesFires on the trigger when its tooltip is hidden, with the same detail shape as show.
z-tooltip:show{ trigger: HTMLElement; tooltip: HTMLDivElement }bubblesFires on the trigger when its tooltip is shown. Detail carries trigger and tooltip (the shared tooltip element).

Data Hooks

AttributeValuesApplies toRoleDescription
data-side—descendantmarkerSet by the singleton on the tooltip element to the resolved placement side (top, bottom, left, right); selects fixed positioning and the enter-animation direction.
data-tooltip—external-triggerconfigActivates the tooltip on the element. The value is the tooltip text, or an option string with title/text, pos/placement, offset, delay, flip, shift, blur, cls, and stl. A native title attribute is stashed and used as fallback text.

CSS Classes

ClassRoleApplies toDescription
.z-tooltiproot.z-tooltipRoot class of the shared tooltip element (div#z-tooltip-singleton appended to body); hidden until the singleton adds z-active.
.z-tooltip-blurmodifier.z-tooltipApplies a backdrop blur and a slightly translucent background; enabled by the blur option.

Keyboard

KeysActionWhen
EscapeHides the visible (or pending) tooltip.—

Accessibility

  • While shown, the trigger gets aria-describedby="z-tooltip-singleton" and the tooltip element has role="tooltip"; both are restored on hide.
  • Keyboard focus shows the tooltip immediately when :focus-visible matches, so keyboard users get the same hint as pointer users.
  • A stashed native title is restored when the tooltip hides, keeping the browser fallback available.