Skip to main content

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:

PartOnPurpose
data-ui5-has-tooltip="<id>"the openermarks the trigger, drives the gestures
aria-describedby="<id>"the openerauthor-owned accessible description link
<ui5-tooltip id="<id>">text</ui5-tooltip>standaloneholds the text (light-DOM child), renders the popover, is the describedby target
<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​

MemberKindDefaultNotes
child textlight DOMβ€”the text and the aria-describedby source (text only)
placementpropertyTopTop / Bottom / Left / Right
horizontalAlignpropertyCenterpopover horizontal alignment
openTooltip() / closeTooltip() / isOpen()methodsβ€”imperative control

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 via event.composedPath() (so openers inside a component's shadow root are found) and drives the matching tooltip.
  • Accessibility. aria-describedby on the opener references the <ui5-tooltip>; the host reflects role="tooltip", and aria-describedby resolves the tooltip's light-DOM text as the description directly β€” no aria-label mirror 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 native popover="manual" attribute (display:none when 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​

  1. The <ui5-tooltip> primitive + data-ui5-has-tooltip, with its own test page.
  2. Later: replace native title across components (the migration surface is in Tooltip-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.

DimensionA. data-attr (chosen)B. openerC. ref+helperD. prop spreadE. wrapperF. native titleG. magic attr
Plain HTML (1)βœ…βœ…βŒβŒβœ…βœ…βœ…
Listeners (2)delegatedper-openerper-openerper-openerowned childnativedelegated+observed
Leak-proof (3)βœ…βš οΈ observer⚠️ wrong unmountβœ…βœ…βœ…βœ…βš οΈ observer
ARIA (4)author-ownedmanualmanualvia helpercross-shadow⚠️ conflictshard pre-open
Rich contentlater (slot)laterβœ…βœ…βœ…βŒβŒ
Layout impactnonenonenonenone❌ nodenonenone

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.

FrameworkShapeText viaPlacementDelaysControlledA11y note
Material UIwrappertitle (node)placement (14)enter/leave, touchopen/onOpen/onClosedescribeChild toggles label↔description
Ant Designwrappertitle (node/fn)placement (12)mouseEnter/Leaveopen/onOpenChangetrigger enum
React Ariacompositionchildrenplacement (6)delay + warmup/cooldownisOpen/onOpenChangerole=tooltip; strongest
shadcn/Radixcomposition + providerchildrensideprovider delay/skipDelayopen/onOpenChangeRadix a11y built-in
Vaadinslot (web component)text attrpositionhover/focus/hide + static globalsmanual + openedblur closes instantly

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.