Tooltip
ui5-tooltip shows a short, non-interactive text near an element. The element it
describes points at the tooltip; the tooltip owns the visual and the accessible
description.
API at a glanceβ
Three parts:
<button data-ui5-has-tooltip="t1" aria-describedby="t1">Save</button>
<ui5-tooltip id="t1">Save the document</ui5-tooltip>
Being plain attributes, this works in React, any framework, and plain HTML. The
association is a string id β there is no HTMLElement/opener form (an
attribute is a string, and aria-describedby is itself a string IDREF).
For app developers consuming a UI5 component, the component wires all three parts internally and exposes a simple property:
<ui5-button tooltip="Save the document">Save</ui5-button>
<ui5-tooltip> surfaceβ
Opens on hover, keyboard focus and long-press; closes on Escape, activation, or when the pointer/focus leaves. The open/close delay is a fixed internal value (500ms), not configurable; touch/Escape act immediately.
How it worksβ
- Opener-centric. The opener names the tooltip; the tooltip carries no opener reference. Nothing to observe on the opener, nothing to tear down when it is removed β leak-proof.
- One document-level listener set. Attached when the first
<ui5-tooltip>connects, detached when the last disconnects. Each event resolves the opener viaevent.composedPath()(so openers inside a component's shadow root are found) and drives the matching tooltip. - Accessibility.
aria-describedbyon the opener references the<ui5-tooltip>; the host reflectsrole="tooltip", andaria-describedbyresolves the tooltip's light-DOM text as the description directly β noaria-labelmirror is needed. Verified in Chrome and Firefox (accname-1.1 resolves hidden referenced nodes, so the description computes even while the host is hidden). The host is hidden via the nativepopover="manual"attribute (display:nonewhen closed, zero layout footprint; promoted to the top layer when open), not a clip hack. - Internal usage. For UI5 components the
<ui5-tooltip>is rendered inside the component's root element where the HTML content model allows it (e.g. inside the<button>for ui5-button). A couple of hosts keep it as a sibling for documented structural reasons: Icon's SVG branch (a custom element can't nest in<svg>) and Title (its heading is built by a per-level helper).
Double-announcement (review when migrating)β
When a host already exposes the same text as its accessible name (icon-only
button, ui5-icon) or via aria-description (Button, Link, Switch), adding
aria-describedby to the same text double-announces it. Migrated components set
data-ui5-has-tooltip for the gesture but rely on the existing ARIA instead of
adding aria-describedby; each site carries a review comment. Decide per host.
Native titleβ
A raw native title an author writes on a UI5 host is left to the browser β not
hijacked or suppressed. Components expose their styled tooltip via the tooltip
property.
Shipping in two stagesβ
- The
<ui5-tooltip>primitive +data-ui5-has-tooltip, with its own test page. - Later: replace native
titleacross components (the migration surface is inTooltip-stats.md).
Future developmentβ
A slot="tooltip" form (<ui5-button><ui5-tooltip slot="tooltip">β¦</ui5-tooltip></ui5-button>)
would let app developers attach a tooltip to any component without a tooltip
property. Deferred β it reintroduces a per-host association the attribute model
avoids.
Why this designβ
Requirements: (1) framework-agnostic, (2) performant, (3) lifecycle-reliable
(never leaks or goes stale), (4) aria-describedby.
A. data-attr + aria-describedby (chosen)β
Declarative attribute drives gestures via document delegation; aria-describedby
author-owned; light-DOM text is the description. Pro: plain HTML anywhere, no
opener listeners/lifecycle/observer, leak-proof. Con: new public attribute;
invokerβtooltip inversion; needs global document-level attachment (a correct,
cheaper-than-per-opener delegation trade).
B. <ui5-tooltip opener="id">β
Tooltip references its opener; listeners on the resolved opener. The previous model. Con: needs a removal observer that is load-bearing for memory-safety β misses ancestor-removal, reparent, cross-shadow β the leak returns. The reason for the pivot to A.
C. ref + helperβ
ref={el => helper.attach(el)}. Con: not usable from plain HTML; ref(null)
fires on template unmount, not opener removal.
D. prop spreadβ
{...tooltipBindings({ text })}. Con: not plain-HTML; loses attach-by-id;
opaque. Internal sugar only.
E. wrapperβ
Tooltip wraps the trigger (Radix/MUI asChild, Shoelace). Con: extra DOM node;
single-child constraint; awkward across the UI5 shadow boundary; display:contents
has a11y-tree problems.
F. reuse native titleβ
Intercept title, suppress the native bubble, show a styled popover. Con
(disqualifying): the native bubble can't be reliably suppressed; string-only, no
styling/placement/delay; title already feeds the accessible name β
double-announce; ambiguous across the shadow boundary. Rejected.
G. magic attribute (auto-attach, no component)β
A single attribute the framework detects and auto-attaches a tooltip to, with no
authored <ui5-tooltip>. Con: needs a persistent cross-shadow-root
MutationObserver (edges back toward OpenUI5 TooltipEnablement); string-only; no
stable node to point aria-describedby at before open; no types/autocomplete.
Verdict: a good ergonomic layer on top of A for the plain-text case, not a
replacement β A keeps the attribute but pairs it with a real node, giving the
stable describedby target G lacks.
React prop-getter layer (detail of A, not exported)β
For React consumers the same contract can be a hook composing trigger props
(onMouseEnter/Leave/onFocus/Blur) and merging aria-describedby (split,
dedupe) with the tooltip id, plus a tooltip component owning the popover; hover and
focus tracked separately so leaving a focused trigger does not close it. A
consumer-side convenience over the same model β a design detail, not shipped API.
Statisticsβ
See Tooltip-stats.md β components with a public tooltip
property, components using native title, and the interactive/non-interactive
split (the stage-2 migration surface).
Cross-framework referenceβ
Two API shapes dominate: wrapper/text-prop (Material UI, Ant Design β the
tooltip wraps the trigger, text is a prop) and composition/slot (React Aria,
shadcn/Radix, Vaadin β separate elements, structural association). Vaadin is the
closest peer: a real <vaadin-tooltip> in a tooltip slot with a for-by-id
association mirroring our attribute link.
Material UI β wrapper + title prop; the single child is the trigger.
<Tooltip title="Delete" placement="top" arrow enterDelay={100}>
<Button>Delete</Button>
</Tooltip>
Ant Design β same wrapper shape; trigger is one enum rather than three
disable* flags.
<Tooltip title="prompt text" placement="topLeft" trigger="hover">
<Button>TL</Button>
</Tooltip>
React Aria β composition; trigger and tooltip are siblings inside a
TooltipTrigger, behavior config on the trigger, text as the tooltip's children.
<TooltipTrigger delay={1500} trigger="focus" placement="top">
<Button aria-label="Edit"><Edit /></Button>
<Tooltip>Edit</Tooltip>
</TooltipTrigger>
shadcn/ui (Radix) β composition + a root TooltipProvider; asChild merges
behavior onto your own element instead of rendering an extra one.
<Tooltip>
<TooltipTrigger asChild><Button>Hover</Button></TooltipTrigger>
<TooltipContent side="top">Add to library</TooltipContent>
</Tooltip>
Vaadin β slot-based web component; text via the text attribute, or associate
by id with for when not slotting.
<vaadin-button>
Click me
<vaadin-tooltip slot="tooltip" text="Home"></vaadin-tooltip>
</vaadin-button>
Design points adopted: text-only content, placement enum name, a fixed internal
open/close delay (not a public property), role="tooltip" + description as the
correct default, and Vaadin's "blur closes immediately".
The full per-framework survey β complete API snippets, key props, and notes β is in
Tooltip-framework-survey.md.
Sources: MUI mui.com/material-ui/react-tooltip Β· Ant ant.design/components/tooltip
Β· React Aria react-aria.adobe.com/Tooltip Β· shadcn
ui.shadcn.com/docs/components/radix/tooltip Β· Vaadin
vaadin.com/docs/latest/components/tooltip.