Tooltip

Tooltips display brief labels or messages.

Usage

Tooltip displays informative text when users hover, focus, or click a trigger. Each framework delivers it in the shape it is built for:

  • React exports a Tooltip component that wraps a single trigger child, or targets one through targetRef.
  • Angular exports a Tooltip directive, [udxTooltip], that you put directly on the trigger. It injects its own ElementRef, so there is no target to hand over. Its inputs are prefixed udxTooltip* because the host element is not the directive’s own.
  • Svelte exports a tooltip attachment, {@attach tooltip(() => ({ … }))}, that you put directly on the trigger — the Svelte counterpart of the Angular directive. Its options are read through a function, so a change updates the open tooltip in place.

The concept, the vocabulary, the behavior and the accessibility are identical; only the way you reach them differs.

bash
import { Tooltip } from "@udixio/ui-react"

Use trigger (“hover”, “focus”, “click”, or an array of these) to control how the tooltip appears, and position to place it relative to its target.

Rich content

variant="rich" renders a card-like surface with a title, text, and optional buttons. Supply custom content instead – content in React, a TemplateRef passed to udxTooltipContent in Angular, a snippet passed to content in Svelte – to replace that built-in layout entirely; the layout only renders when no custom content is given.

Controlled state

Use open with onOpenChange (React and Svelte), or udxTooltipOpen with udxTooltipOpenChange (Angular), to fully control visibility. defaultOpen initializes uncontrolled state.

Migrating from <udx-tooltip>

The Angular adapter was a udx-tooltip component taking a required target input. It is removed, with no compatibility alias. Move it onto the trigger and drop the target:

html
<!-- before -->
<udx-button #trigger label="Save" />
<udx-tooltip [target]="triggerRef()" text="Save the draft" />

<!-- after -->
<udx-button label="Save" udxTooltip="Save the draft" />

Every other input keeps its meaning under a udxTooltip* alias, and <ng-content> becomes a TemplateRef on udxTooltipContent. The viewChild and ElementRef plumbing the old form required disappears entirely.

Delays

Use openDelay and closeDelay (ms) to tune the hover/focus behavior – udxTooltipOpenDelay and udxTooltipCloseDelay in Angular. Defaults: 400ms and 150ms. Focus and click transitions are immediate. On touch, a long press opens the tooltip after 500ms; after release or cancellation, it remains visible for 1.5 seconds as specified by Material 3.

One shared implementation

Two controllers in @udixio/core/dom carry the behavior, and both adapters drive them rather than reimplementing anything:

  • createTooltipTriggerController owns the timers, the pointer, keyboard and touch wiring, the touch long press, aria-describedby, and the arbitration that closes one tooltip when another opens.
  • createTooltipTransitionController owns the open/close opacity and height transition, with Anime.js.

React, Angular and Svelte therefore share identical timing, reduced-motion behavior, interruption handling and cleanup, by construction rather than by discipline. Override the transition timing with transition (udxTooltipTransition), taking { duration, ease }.

Position

Tooltip renders through AnchorPositioner, which uses native CSS Anchor Positioning where supported and falls back to tracking the target’s getBoundingClientRect() otherwise. position accepts top, bottom, left, right, top-left, top-right, bottom-left, or bottom-right; it defaults to bottom-right for variant="rich" and bottom otherwise.

The four single keywords sit on one side of the target and stay centred on the other axis. The four corners name a cell of the 3x3 grid around the target, so they sit diagonally outside its box on both axes: bottom-right places the tooltip below the target’s bottom edge and past its right edge – not below it, right-aligned. Both the native and the fallback path resolve them the same way.

Keyboard

KeysActions
TabFocus lands on the target element, if focusable
EscapeCloses an open tooltip

Accessibility

Only one tooltip is visible at a time. Opening a tooltip dismisses the previously visible tooltip, including when controlled tooltips are used.

  • Provides role="tooltip" and links to its target via aria-describedby when open.
  • The tooltip surface stays mounted at all times, hidden with inert and aria-hidden rather than unmounted, so it can animate out; expensive custom content is not torn down until Tooltip itself unmounts.