Tooltip
Introduction
Section titled “Introduction”A short text hint for a trigger, meeting WCAG 1.4.13 (Content on Hover or Focus). It shows after a delay on pointer hover and immediately on keyboard focus. The pointer can move onto it (hoverable), it stays visible while the trigger is hovered or focused (persistent), and Escape hides it without moving focus (dismissible). The trigger references it through aria-describedby, or through aria-labelledby for icon-only controls. Only one tooltip is visible at a time.
- Hover and focusShows on pointer hover and keyboard focus, and hides on Escape.
- Label or descriptionDescribes its trigger, or names an icon-only control as its label.
- Tunable delaysShow and hide delays keep tooltips from flickering while the pointer moves.
- Smart placementPrefers a side you choose and flips to stay inside the viewport.
Use it for
- Supplementary hints: keyboard shortcuts, the full text of a truncated label, the purpose of an icon-only button.
- Naming an icon-only control visually as well as programmatically (relation ‘label’).
Use something else for
- Essential information or instructions: touch users never see tooltips; put it on the page.
- Interactive content (links, buttons): use Popover.
- Validation errors: use the field’s validation message.
- Long text: tooltips are capped at tooltip-max-width; use Popover or inline help.
Anatomy
<button aria-describedby=tooltip>Save</button> (consumer trigger)...<div class="aui-tooltip" role="tooltip" popover="manual">Ctrl+S</div> (end of body, or the trigger's <dialog>)Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Tooltip in the Overlays showcase
Section titled “Tooltip in the Overlays showcase”The part of the Overlays showcase that uses Tooltip. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.
Showcase source
// Overlays showcase: a dialog with a confirmation flow, an alert dialog, drawers from each side,// a bottom sheet with snap points, a popover form, tooltips, and a hover card.import { Button } from '@absoluteui/components/button';import { BottomSheet } from '@absoluteui/components/bottom-sheet';import { Dialog } from '@absoluteui/components/dialog';import { Drawer } from '@absoluteui/components/drawer';import { HoverCard } from '@absoluteui/components/hover-card';import { Popover } from '@absoluteui/components/popover';import { TextInput } from '@absoluteui/components/text-input';import { Tooltip } from '@absoluteui/components/tooltip';import { choice, createShowcase, hostIn, section, toggle } from './kit.js';
const sc = createShowcase({ title: 'Overlays', description: 'Open each overlay with the mouse or keyboard. Focus moves in and returns to the opener; Escape closes.',});
let closeOnBackdrop = true;let placement: 'start' | 'end' | 'top' | 'bottom' = 'end';
const row = (parent: HTMLElement): HTMLElement => { const r = hostIn(parent); r.className = 'sc-row'; return r;};const opener = (parent: HTMLElement, text: string, variant: 'primary' | 'secondary' | 'danger' = 'secondary'): Button => { const b = Button.create({ text, variant }, document); parent.append(b.element); return b;};const hint = (text: string): HTMLElement => { const p = document.createElement('span'); p.className = 'sc-hint'; p.textContent = text; return p;};const track = (el: HTMLElement, name: string): void => { sc.listen(el, ['aui-open', 'aui-close'], name);};
// Dialogs.const dialogs = row(section(sc, 'Dialogs', ['dialog']));const edit = opener(dialogs, 'Edit name', 'primary');edit.element.addEventListener('click', () => { const body = document.createElement('div'); const field = TextInput.create(hostIn(body), { label: 'Display name', value: 'Ada Lovelace', required: true }); const d = Dialog.create({ title: 'Edit display name', description: 'Shown to everyone in your organization.', content: body, closeOnBackdrop, actions: [{ label: 'Cancel', value: 'cancel' }, { label: 'Save', value: 'save', variant: 'primary' }] }); track(d.element, 'dialog'); d.element.addEventListener('aui-cancel', (e) => { // Keep the dialog open while the field is invalid. if ((e as CustomEvent<{ returnValue: string }>).detail.returnValue === 'save' && !field.reportValidity()) e.preventDefault(); }); d.element.addEventListener('aui-close', () => { queueMicrotask(() => { d.destroy(); }); }); d.open();});const del = opener(dialogs, 'Delete account', 'danger');del.element.addEventListener('click', () => { const d = Dialog.create({ role: 'alertdialog', title: 'Delete your account?', description: 'All your data is removed. This cannot be undone.', size: 'sm', actions: [{ label: 'Keep account', value: 'keep', autofocus: true }, { label: 'Delete', value: 'delete', variant: 'danger' }] }); track(d.element, 'alert dialog'); d.element.addEventListener('aui-close', () => { queueMicrotask(() => { d.destroy(); }); }); d.open();});
// Drawer and bottom sheet.const filters = opener(row(section(sc, 'Drawer', ['drawer'])), 'Open filters drawer');filters.element.addEventListener('click', () => { const body = document.createElement('div'); TextInput.create(hostIn(body), { label: 'Search people', type: 'search' }); const d = Drawer.create({ title: 'Filters', content: body, placement, closeOnBackdrop, actions: [{ label: 'Reset', value: 'reset' }, { label: 'Apply', value: 'apply', variant: 'primary' }] }); track(d.element, 'drawer'); d.element.addEventListener('aui-close', () => { queueMicrotask(() => { d.destroy(); }); }); d.open();});const sheet = opener(row(section(sc, 'Bottom sheet', ['bottom-sheet'])), 'Open bottom sheet');sheet.element.addEventListener('click', () => { const s = BottomSheet.create({ title: 'Share', description: 'Drag the handle or use the snap points.', content: 'Copy link, email, or download as PDF.', snapPoints: [0.4, 0.9], closeOnBackdrop }); track(s.element, 'bottom sheet'); sc.listen(s.element, ['aui-snap-change'], 'bottom sheet'); s.element.addEventListener('aui-close', () => { queueMicrotask(() => { s.destroy(); }); }); s.open();});
// Anchored overlays.const pop = opener(row(section(sc, 'Popover', ['popover'])), 'Quick note');const noteBody = document.createElement('div');TextInput.create(hostIn(noteBody), { label: 'Note' });const popover = Popover.create(pop.element, { title: 'Add a note', content: noteBody, showCloseButton: true });track(pop.element, 'popover');const help = Button.create({ icon: 'info', label: 'Help', variant: 'ghost' }, document);row(section(sc, 'Tooltip', ['tooltip'])).append(help.element, hint('Hover or focus the help button.'));const tip = Tooltip.create(help.element, { content: 'Notes are visible only to you.', relation: 'description' });const profile = document.createElement('a');profile.href = '#ada';profile.className = 'aui-link';profile.textContent = 'Ada Lovelace';profile.addEventListener('click', (e) => { e.preventDefault();});row(section(sc, 'Hover card', ['hover-card'])).append(profile, hint('Hover or focus the name for the profile card.'));const card = document.createElement('div');card.textContent = 'Engineering lead, London. Joined 2019.';const hover = HoverCard.create(profile, { content: card, describe: true });track(help.element, 'tooltip');track(profile, 'hover card');
choice( sc, 'Drawer side', [ { value: 'end', label: 'End' }, { value: 'start', label: 'Start' }, { value: 'top', label: 'Top' }, { value: 'bottom', label: 'Bottom' }, ], 'end', (v) => { placement = v; }, ['drawer'],);choice( sc, 'Anchored placement', [ { value: 'bottom', label: 'Below' }, { value: 'top', label: 'Above' }, { value: 'right', label: 'Right' }, { value: 'left', label: 'Left' }, ], 'bottom', (p) => { popover.update({ placement: p }); tip.update({ placement: p }); hover.update({ placement: p }); }, ['popover', 'tooltip', 'hover-card'],);toggle(sc, 'Close on backdrop', true, (v) => { closeOnBackdrop = v;}, ['dialog', 'drawer', 'bottom-sheet']);Keyboard shortcut hint
Section titled “Keyboard shortcut hint”import { Tooltip } from '@absoluteui/components/tooltip';import { Button } from '@absoluteui/components/button';
const save = document.createElement('button');save.type = 'button';save.textContent = 'Save';Button.enhance(save);document.body.append(save);Tooltip.create(save, { content: 'Ctrl+S' });Name an icon-only button
Section titled “Name an icon-only button”import { Tooltip } from '@absoluteui/components/tooltip';import { Button } from '@absoluteui/components/button';
const settings = document.createElement('button');settings.type = 'button';document.body.append(settings);// The tooltip names the icon-only button (aria-labelledby), so create it before the Button.Tooltip.create(settings, { content: 'Settings', relation: 'label', placement: 'bottom' });Button.enhance(settings, { icon: 'menu', variant: 'ghost' });Global delays
Section titled “Global delays”import { configureAbsoluteUI } from '@absoluteui/core';
configureAbsoluteUI({ components: { tooltip: { showDelay: 300, hideDelay: 200 } } });Install and start
Section titled “Install and start”npm install @absoluteui/components @absoluteui/core @absoluteui/themeRegistry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.
import { Tooltip } from '@absoluteui/components/tooltip';import '@absoluteui/components/tooltip/style.css';First use
Section titled “First use”import { Tooltip } from '@absoluteui/components/tooltip';import '@absoluteui/components/tooltip/style.css';
for (const el of document.querySelectorAll<HTMLElement>('[data-hint]')) { Tooltip.create(el, { content: el.dataset.hint ?? '', placement: 'bottom' });}More usage
import { Tooltip } from '@absoluteui/components/tooltip';
const save = document.querySelector<HTMLButtonElement>('#save');if (save) Tooltip.create(save, { content: 'Ctrl+S' });Using Angular? See Tooltip for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”Tooltip.create(trigger: HTMLElement, options: TooltipOptions): TooltipGlobal configuration key: tooltip (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
content |
string |
Tooltip text (text only). Required. | |
relation |
'description' | 'label' |
"description" |
Trigger gets aria-describedby (‘description’) or aria-labelledby (‘label’, for icon-only controls). |
placement |
Placement |
"top" |
Preferred side and logical alignment; flips and shifts to fit. Globally configurable. |
showDelay |
integer (0..5000) |
500 |
Hover delay before showing, ms. Keyboard focus shows immediately. Globally configurable. |
hideDelay |
integer (0..5000) |
100 |
Delay after the pointer leaves the trigger and tooltip before hiding, ms. Globally configurable. |
direction |
'ltr' | 'rtl' |
"ltr" |
Resolves logical start/end placements. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
element |
HTMLDivElement |
The tooltip (div.aui-tooltip[role=tooltip]). |
trigger |
HTMLElement |
The trigger element. |
isVisible |
boolean |
Whether the tooltip is visible. |
options |
Readonly<TooltipOptions> |
Current options. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
show(): void |
Show immediately (hides any other visible tooltip). |
hide(): void |
Hide immediately. |
update(options: Partial<TooltipOptions>): void |
Merge and apply options (content, relation, placement, delays). |
destroy(): void |
Hide; remove the element, the trigger ARIA reference, listeners, and subscriptions. |
Events
Section titled “Events”| Event | Detail | Bubbles | Cancelable | Description |
|---|---|---|---|---|
aui-open |
null |
No | No | After the tooltip became visible (dispatched on the tooltip element). |
aui-close |
null |
No | No | After the tooltip was hidden. |
CSS classes
Section titled “CSS classes”All rules live in the aui.components cascade layer, so application styles override them without specificity battles.
| Class | Purpose |
|---|---|
aui-tooltip |
Tooltip element (manual popover, top layer). |
aui-tooltip--static |
Set when animation is disabled globally. |
Design tokens
Section titled “Design tokens”Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.
--aui-border-width | --aui-color-inverse | --aui-color-on-inverse | --aui-duration-fast | --aui-easing-standard | --aui-font-family-sans | --aui-font-size-sm | --aui-line-height-tight | --aui-radius-sm | --aui-shadow-md | --aui-space-1 | --aui-space-2 | --aui-tooltip-max-width
TypeScript definitions
type TooltipRelation = 'description' | 'label';interface TooltipConfig { placement: Placement; showDelay: number; hideDelay: number }interface TooltipOptions extends Partial<TooltipConfig> { content: string; relation?: TooltipRelation; direction?: 'ltr' | 'rtl' }Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”Pattern: WAI-ARIA APG Tooltip pattern, with WCAG 1.4.13 Content on Hover or Focus.
Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.
Keyboard
Section titled “Keyboard”| Key | Context | Action |
|---|---|---|
| Tab / Shift+Tab | Focus moves to the trigger (keyboard focus-visible) | Shows the tooltip immediately. |
| Tab / Shift+Tab | Focus leaves the trigger | Hides the tooltip. |
| Escape | Tooltip visible | Hides the tooltip without moving focus; the key is consumed. |
| Escape | No tooltip visible | Not handled; reaches enclosing overlays and the page. |
| Element | Role |
|---|---|
| tooltip div | tooltip |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-describedby |
trigger | id of the tooltip, added to existing ids (relation ‘description’) |
aria-labelledby |
trigger | id of the tooltip, added to existing ids (relation ‘label’) |
The tooltip is never focusable and never moves focus. It shows on keyboard focus (:focus-visible) of the trigger, not on pointer focus.
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”| Criterion | Level | Note |
|---|---|---|
| 1.3.1 Info and Relationships | A | |
| 1.4.3 Contrast (Minimum) | AA | |
| 1.4.11 Non-text Contrast | AA | |
| 1.4.13 Content on Hover or Focus | AA | |
| 2.1.1 Keyboard | A | |
| 4.1.2 Name, Role, Value | A |
Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- 1.4.13 dismissible: Escape hides it without moving pointer or focus.
- 1.4.13 hoverable: moving the pointer from the trigger onto the tooltip keeps it open (hideDelay grace period).
- 1.4.13 persistent: stays visible while the trigger is hovered or focused, until Escape or another tooltip opens.
- Only one tooltip is visible at a time.
- Touch pointers do not show tooltips; tooltips must never hold essential information.
- Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/tooltip |
13.0 kB | 5.2 kB | 4.6 kB | 0.5 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| Tooltip.create, per instance | < 1 ms average in headless Chromium |
Tested scale: One visible tooltip at a time by design; instances attach five listeners to the trigger and two to the tooltip.
Five listeners on the trigger, two on the tooltip, and one configuration subscription per instance. While visible: one overlay-stack entry, one window pointerdown listener, and the positioning engine’s observers, all released on hide.
Measured run times: Performance.
Details
Section titled “Details”States
hidden, pending (show delay running), visible, hiding (hide delay running).
State transitions
| From | Trigger | To |
|---|---|---|
| hidden | mouse or pen enters the trigger | pending; visible after showDelay |
| pending | pointer leaves the trigger | hidden (never shown) |
| hidden | keyboard focus on the trigger (:focus-visible) |
visible immediately |
| visible | pointer leaves trigger and tooltip (not keyboard-focused) | hiding; hidden after hideDelay |
| hiding | pointer enters the trigger or the tooltip | visible |
| visible | trigger loses focus, Escape, pointer down elsewhere, another tooltip shows | hidden |
Accessibility notes
- WCAG 1.4.13: dismissible (Escape), hoverable (the pointer can move onto the tooltip within
hideDelay), persistent (stays while hovered or focused). - Pointer focus (a click) does not show the tooltip; keyboard focus does.
- Touch pointers never show tooltips, so tooltips must never hold essential information.
relation: 'label'replaces the trigger’s accessible name; use it only for controls without visible text.- Manual screen-reader verification is pending (see Known limitations).
Responsive behavior
Width up to min(tooltip-max-width, 100vw - 1rem); text wraps. The positioning engine flips and shifts to stay in the viewport.
Right-to-left
start and end placements are logical and mirror in RTL (direction option or global direction).
Theming
Inverse surface (color-inverse with color-on-inverse text), verified in the light, dark, and high-contrast themes. In forced-colors mode the tooltip has a CanvasText border. The fade-in uses @starting-style and is removed under reduced motion or animation: 'none'.
Global configuration
configureAbsoluteUI({ components: { tooltip: { showDelay: 300, hideDelay: 200 } } });Changes apply to existing instances (a visible tooltip is repositioned).
Component configuration
Instance options override global and theme defaults. All options are dynamic.
Security
Content is set with textContent and never parsed as HTML. CSP-safe: positioning uses the CSSOM.
Data handling
No persistence, network access, or telemetry.
Supported data scale
Any number of instances per page; at most one is visible at a time.
Edge cases
- Moving the pointer straight from the trigger onto the tooltip keeps it open, even with
hideDelay: 0(hiding is always asynchronous). - A tooltip shown by keyboard focus stays visible when the pointer leaves.
- Inside a Popover, the first Escape hides the tooltip and the second closes the popover.
- Pointer down outside the trigger and tooltip hides the tooltip before the overlay stack runs, so the overlay below still gets its outside-pointer dismissal.
- Inside a modal
<dialog>, the tooltip is appended to that dialog so it stays hoverable (the rest of the page is inert).
Errors
| Code | Category | Cause |
|---|---|---|
TOOLTIP_TRIGGER |
configuration | The trigger is not a connected HTMLElement. |
TOOLTIP_OPTIONS |
configuration | Empty or non-string content, or an invalid relation. |
CFG_* |
configuration | Invalid placement, showDelay, or hideDelay. |
A failed construction leaves no element, ARIA reference, listeners, or subscriptions behind. A failed update() keeps the previous options.
Known limitations
- Touch pointers never show the tooltip.
- Disabled native buttons get no pointer or focus events; use
aria-disabledif they need a tooltip. - One visible tooltip per loaded copy of the module.
- The trigger gap is fixed at 6 px.
- Screen-reader behavior has not yet been manually verified with NVDA, JAWS, and VoiceOver.
Unsupported scenarios
- Rich or interactive content (use Popover).
- Showing on tap or long press.
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.