overlayscss
Tooltip
Singleton text hint shown on hover or keyboard focus of any data-tooltip element, positioned with Floating UI.
CSS Variables
| Variable | Default | Scope | Description |
|---|---|---|---|
--z-tooltip-bg | var(--z-primary) | .z-tooltip | Background base color, mixed with transparency using --z-tooltip-bg-o. |
--z-tooltip-bg-o | 100% | .z-tooltip | Background opacity percentage used in the background color mix. |
--z-tooltip-blur | var(--z-global-blur) | .z-tooltip | Backdrop blur radius used by .z-tooltip-blur. |
--z-tooltip-color | var(--z-primary-f) | .z-tooltip | Text base color, mixed with transparency using --z-tooltip-color-o. |
--z-tooltip-color-o | 100% | .z-tooltip | Text opacity percentage used in the text color mix. |
--z-tooltip-font-size | 0.75rem | .z-tooltip | Font size of the tooltip text. |
--z-tooltip-line-height | 1rem | .z-tooltip | Line height of the tooltip text. |
--z-tooltip-max-width | 208px | .z-tooltip | Maximum width of the tooltip box; text wraps at this width. |
--z-tooltip-padding | 0.375rem 0.75rem | .z-tooltip | Inner padding of the tooltip box. |
--z-tooltip-radius | var(--z-global-radius) | .z-tooltip | Corner radius of the tooltip box. |
--z-tooltip-shadow | var(--z-global-shadow-small) | .z-tooltip | Box shadow of the tooltip box. |
--z-tooltip-slide-x | 0 | .z-tooltip[data-side='top'] | Horizontal enter-slide offset for the current side, used by the z-tooltip-in keyframes. |
--z-tooltip-slide-y | 4px | .z-tooltip[data-side='top'] | Vertical enter-slide offset for the current side, used by the z-tooltip-in keyframes. |
--z-tooltip-z-index | 1030 | .z-tooltip | Stacking order of the tooltip element. |
Events
| Event | Detail | Flags | Description |
|---|---|---|---|
z-tooltip:hide | { trigger: HTMLElement; tooltip: HTMLDivElement } | bubbles | Fires on the trigger when its tooltip is hidden, with the same detail shape as show. |
z-tooltip:show | { trigger: HTMLElement; tooltip: HTMLDivElement } | bubbles | Fires on the trigger when its tooltip is shown. Detail carries trigger and tooltip (the shared tooltip element). |
Data Hooks
| Attribute | Values | Applies to | Role | Description |
|---|---|---|---|---|
data-side | — | descendant | marker | Set 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-trigger | config | Activates 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
| Class | Role | Applies to | Description |
|---|---|---|---|
.z-tooltip | root | .z-tooltip | Root class of the shared tooltip element (div#z-tooltip-singleton appended to body); hidden until the singleton adds z-active. |
.z-tooltip-blur | modifier | .z-tooltip | Applies a backdrop blur and a slightly translucent background; enabled by the blur option. |
Keyboard
| Keys | Action | When |
|---|---|---|
| Escape | Hides the visible (or pending) tooltip. | — |
Accessibility
- While shown, the trigger gets
aria-describedby="z-tooltip-singleton"and the tooltip element hasrole="tooltip"; both are restored on hide. - Keyboard focus shows the tooltip immediately when
:focus-visiblematches, so keyboard users get the same hint as pointer users. - A stashed native
titleis restored when the tooltip hides, keeping the browser fallback available.