Tooltip

Updated: Sep 24, 2026
Tooltip is not a surface — it is the manager that shows short supplemental context next to an anchor element, positions it inside the visible bounds, animates it in and out, and tears it down. The surface it paints is TooltipContainer.
Use a tooltip to name an unfamiliar icon-only control, or to explain why a control cannot be used right now. Do not repeat a label the user can already read, and do not put instructions that matter only in a tooltip — it is transient by design.
There are three ways to get one, in order of preference:
  1. Tooltip props on a control. Every component built on InteractableBase — Button, Container, ListItem, and the rest — accepts tooltipText and a tooltipMode. This wires up focus, dismissal, and the single-tooltip-at-a-time rule for you.
  2. useTooltip. An imperative handle plus a portal node you render, for anchors that are not the toolkit controls or for tooltips driven by your own logic.
  3. Tooltip. A declarative wrapper over useTooltip that takes an anchorRef and an isVisible flag.

Usage

From a control

import { Button, TooltipMode } from '@wearables-ui-toolkit/mrbd';

<Button
  icon={captureIcon}
  ariaLabel="Capture"
  tooltipText="Capture"
  tooltipMode={TooltipMode.DWELL}
  onActivate={capture}
/>
Explain an unavailable control instead of leaving the user guessing:
<Button
  title="Send"
  disabled={!isConnected}
  tooltipText="Reconnect to send"
  tooltipMode={TooltipMode.DISABLED_CLICK}
  onActivate={send}
/>

With the hook

Render tooltip.portal from the component that owns the anchor. It is null while nothing is showing.
import { useRef } from 'react';
import { useTooltip } from '@wearables-ui-toolkit/mrbd';

export function ZoomReadout({ zoomLabel }: { zoomLabel: string }) {
  const anchorRef = useRef<HTMLDivElement>(null);
  const tooltip = useTooltip();

  return (
    <div
      ref={anchorRef}
      tabIndex={0}
      onFocus={() => {
        const anchor = anchorRef.current;
        if (anchor) {
          tooltip.show(anchor, { text: 'Zoom', metadata: zoomLabel });
        }
      }}
      onBlur={() => tooltip.hide()}
    >
      {zoomLabel}
      {tooltip.portal}
    </div>
  );
}
Use update rather than show when only the content changes, so a live readout does not restart its entrance animation on every value:
const anchor = anchorRef.current;
if (anchor) {
  tooltip.update(anchor, { text: 'Zoom', metadata: zoomLabel });
}

With the component

anchorRef must reference a DOM element. The toolkit control refs are component handles, not elements, so anchor to an element you own — or use the tooltip props on the control, which is what they are for.
import { useRef, useState } from 'react';
import { Tooltip, TooltipPosition } from '@wearables-ui-toolkit/mrbd';

export function ReorderHint({ children }: { children: React.ReactNode }) {
  const anchorRef = useRef<HTMLDivElement>(null);
  const [isHintVisible, setHintVisible] = useState(true);

  return (
    <div ref={anchorRef}>
      {children}
      <Tooltip
        anchorRef={anchorRef}
        text="Long-press to reorder"
        isVisible={isHintVisible}
        position={TooltipPosition.ANCHORED}
        shouldAutoDismiss
        onHide={() => setHintVisible(false)}
      />
    </div>
  );
}

Props

The full prop type is TooltipProps. Tooltip renders nothing of its own; it drives useTooltip from props and returns that hook’s portal.
PropTypeDefaultDescription
anchorRef
RefObject<HTMLElement \| null>
—
Required. The element the tooltip points at. Must be mounted while the tooltip is visible.
text
string
—
Primary text.
metadata
string
—
Secondary text shown after the primary text.
icon
IconSource
—
Leading icon.
trailingIcon
IconSource
—
Trailing icon.
content
ReactNode
—
Custom content rendered instead of the built-in container. Suppresses text, metadata, and both icons.
contentDescription
string
—
Accessible name. Falls back to text and metadata joined.
isFocusable
boolean
false
Lets the overlay take pointer events. Required for interactive custom content.
tracksAnchorScale
boolean
false
Follows an anchor that is being scaled or animated, re-measuring every frame.
centerPositionProvider
TooltipCenterPositionProvider
—
Supplies the point the tooltip should point at, relative to the anchor.
targetRectProvider
TooltipTargetRectProvider
—
Supplies the rectangle the tooltip should point at, relative to the anchor.
isVisible
boolean
false
Shows or hides the tooltip.
onHide
() => void
—
Called once when the tooltip stops being presented, at the start of its exit fade rather than at the end of it.
position
TooltipPosition
TooltipPosition.ANCHORED
Preferred placement.
shouldAutoDismiss
boolean
false
Hides the tooltip on its own 5000 ms after it is shown.
showTooltipTail
boolean
true
Draws the pointer tail on the built-in container.

InteractableBase

Every control built on InteractableBase carries its own tooltip props, and that is the preferred way to attach one. Read that page for the rest of the interaction contract.
PropTypeDefaultDescription
tooltipText
string
—
Primary text. Nothing shows without this or tooltipContent.
tooltipMetadata
string
—
Secondary text.
tooltipContent
ReactNode
—
Custom content instead of the built-in container.
tooltipContentDescription
string
—
Accessible name for the tooltip.
tooltipMode
TooltipMode
TooltipMode.NONE
When the tooltip appears.
tooltipPosition
TooltipPosition
TooltipPosition.ANCHORED
Preferred placement.
tooltipShowTail
boolean
true
Draws the pointer tail.
tooltipFocusable
boolean
false
Lets the tooltip take focus, for interactive custom content such as a menu.
tooltipHidesFocusState
boolean
false
Suppresses the control’s focus visuals while its tooltip is up.
tooltipCenterPositionProvider
TooltipCenterPositionProvider
—
Anchor-relative point to point at.
tooltipTargetRectProvider
TooltipTargetRectProvider
—
Anchor-relative rectangle to point at.
A control’s tooltip has no icon props: tooltipText and tooltipMetadata are the only built-in content it can draw. Use tooltipContent when you need an icon, and pass it a TooltipContainer so the surface still matches.

Imperative handle

useTooltip() returns a TooltipState.
MemberTypeDescription
isShowing
boolean
true while a tooltip is presented and not yet dismissing.
portal
ReactNode
The portalled overlay. Render it; it is null when nothing is showing.
show
(anchor: HTMLElement, options: TooltipShowOptions) => void
Presents a tooltip against anchor. Replaces any tooltip this hook is already showing and fires that one’s onHide first. Does nothing when the options carry no content.
update
(anchor: HTMLElement, options: TooltipShowOptions) => void
Swaps the content of a tooltip already showing on the same anchor without restarting the presentation. Falls back to show for a different anchor or when nothing is showing, and hides when the content becomes empty.
hide
(animated?: boolean) => void
Hides the tooltip. animated defaults to true, which fades out before firing onHide; false tears it down immediately.
refreshPosition
() => void
Recomputes the position immediately, for anchor movement the manager cannot observe.

Types and enums

TooltipPosition

MemberValueDescription
ANCHORED
'anchored'
Above the anchor. Tail points down.
ANCHORED_BOTTOM
'anchoredBottom'
Below the anchor. Tail points up.
CENTERED
'centered'
Horizontally centred within the tooltip bounds rather than on the anchor, and placed above it vertically. A control’s CENTERED tooltip draws no tail; through Tooltip or useTooltip the built-in surface still draws one, so pass showTooltipTail={false} alongside it.

TooltipMode

MemberValueDescription
NONE
'none'
No tooltip. The default.
FOCUSED
'focused'
Shows while the control is focused or pressed.
DWELL
'dwell'
Shows once the control has been focused or pressed continuously for 3000 ms.
DISABLED_CLICK
'disabledClick'
Shows when a disabled control is activated, then hides itself 5000 ms later.
ALWAYS
'always'
Shown for as long as the control is mounted with tooltip content.

TooltipShowOptions

The options bag show and update take. It carries the same content, placement, and provider fields as the component props, plus onHide.
FieldTypeDefaultDescription
text
string
—
Primary text.
metadata
string
—
Secondary text.
icon
IconSource
—
Leading icon.
trailingIcon
IconSource
—
Trailing icon.
content
ReactNode
—
Custom content instead of the built-in container.
contentDescription
string
—
Accessible name.
isFocusable
boolean
—
Lets the overlay take pointer events.
tracksAnchorScale
boolean
—
Re-measures the anchor every frame.
centerPositionProvider
TooltipCenterPositionProvider
—
Anchor-relative point to point at.
targetRectProvider
TooltipTargetRectProvider
—
Anchor-relative rectangle to point at.
shouldAutoDismiss
boolean
false
Hides the tooltip 5000 ms after it is shown.
position
TooltipPosition
TooltipPosition.ANCHORED
Preferred placement.
showTooltipTail
boolean
true
Draws the pointer tail on the built-in container.
onHide
() => void
—
Fires exactly once when this presentation ends, whether it was hidden explicitly, replaced by another show, or auto-dismissed.

TooltipState

The object useTooltip() returns. Its members are listed under Imperative handle above: isShowing, portal, show, update, hide, and refreshPosition.

Position providers

TypeSignatureDescription
TooltipCenterPositionProvider
(anchor: HTMLElement) => TooltipAnchorPoint \| null \| undefined
Returns the point the tooltip should aim at.
TooltipTargetRectProvider
(anchor: HTMLElement) => TooltipAnchorRect \| null \| undefined
Returns the rectangle the tooltip should aim at.
TooltipAnchorPoint is { x: number; y: number }. TooltipAnchorRect is { left, top, right, bottom } with optional width and height; when width is omitted it is derived from right - left.
Both are read in the anchor’s own coordinate space: the manager adds the anchor’s position to whatever a provider returns. Returning viewport coordinates double-counts that offset and lands the tooltip in the wrong place. Return null to fall back to the anchor’s own box. When both providers are supplied, the rectangle wins for the vertical edges and the point wins for the horizontal centre.

Default tooltip presentation

The Foundation package exports TooltipPresentationProvider for selecting the component used when a tooltip has text or metadata but no custom content:
import {
  TooltipPresentationProvider,
  type DefaultTooltipPresentation,
} from '@wearables-ui-toolkit/foundation';
Its props are:
PropTypeDescription
children
ReactNode
Subtree that uses the presentation.
presentation
DefaultTooltipPresentation
Component that renders the default tooltip content.
DefaultTooltipPresentation receives DefaultTooltipPresentationProps: text, metadata, showTooltipTail, tailDirection, and tailCenterX. The presentation owns its visual markup and must keep text and metadata available to assistive technology.
App installs TooltipContainer for the whole toolkit tree. Prefer the content or tooltipContent prop for a one-off custom tooltip. Use a nested TooltipPresentationProvider only when a subtree needs a different default presentation for every tooltip.

Behavior

  • Content gate. Nothing is presented unless at least one of text, metadata, or content is set. Clearing them all while visible hides the tooltip.
  • Updating in place. While isVisible stays true, Tooltip applies new props through update, so changing the text of a tooltip that is already up swaps the content without restarting the entrance fade.
  • Horizontal placement. The tooltip is centred on the anchor’s centre, or on the point or rectangle a provider returns, then clamped inside the bounds with a small edge inset. CENTERED centres it in the bounds instead.
  • Vertical placement.ANCHORED sits above the anchor and ANCHORED_BOTTOM below it. A tooltip that renders the built-in container always keeps the side you asked for. Only custom content flips to the other side when the requested side cannot fit and the other side has more room — and on a control, only when that content is also focusable, which is the popup case such as a menu.
  • Bounds. Placement and clipping use the nearest ancestor marked as a tooltip boundary — the content root that App renders — and fall back to the viewport. The overlay is clipped to those bounds, so it never spills outside them. A control’s tooltip is additionally pulled back inside them both horizontally and vertically; through Tooltip or useTooltip only the horizontal position is pulled back, so a tooltip anchored too close to the top or bottom edge is trimmed rather than moved. Leave room for it, or ask for the other side.
  • Tail. On the built-in container the tail is drawn unless showTooltipTail={false} removes it, and a control’s CENTERED tooltip has none because it is not aligned to the anchor. Custom content given to Tooltip or useTooltip is rendered exactly as you wrote it and gets no tail; a control instead hands its resolved tail direction and horizontal offset to tooltipContent, which is how ContextMenu draws its own. The gap between tooltip and anchor is larger when there is no tail, so turning the tail off does not leave the surface sitting on the control.
  • Tracking. Position is recomputed when anything in the page scrolls, on window resize, when the tooltip itself resizes, and on refreshPosition. A control’s tooltip additionally re-measures on every animation frame while it is visible, so it stays attached to a control that a CSS transform is moving inside a rail or carousel; a tooltip you drive yourself does not, which is what refreshPosition is for. tracksAnchorScale makes Tooltip and useTooltip measure the anchor’s scaled box every frame too; turn it on only while such an animation runs.
  • Motion. The overlay fades in and out over 300 ms, and stays hidden until it has been measured, so it never flashes at an unplaced position. hide(false) skips the fade entirely and tears the overlay down in the same tick.
  • One at a time. Showing a tooltip through the interactable base hides any other interactable-base tooltip immediately. useTooltip likewise replaces the tooltip it is already showing, firing the replaced tooltip’s onHide first. The two paths do not coordinate with each other, and each useTooltip call site is its own presenter, so a hand-driven tooltip can sit on screen alongside a control’s. Drive at most one hand-managed tooltip per screen.
  • Auto-dismiss is off. Opt in with shouldAutoDismiss for a hint that should disappear on its own.
  • Dismissal. A FOCUSED or DWELL tooltip hides when the control loses focus, except that a FOCUSED tooltip whose custom content is focusable stays up for as long as that content holds focus; a DISABLED_CLICK tooltip hides itself after its dismiss delay. A focusable tooltip from the interactable base — the menu case — also handles Escape and the browser back key: it forwards the key to the popup content, dismisses, returns focus to the anchor, and stops the key before route history sees it. A tooltip driven by useTooltip is yours to hide.
  • Pointer events pass straight through the overlay unless isFocusable is set.
  • The overlay renders into the floating portal root supplied by App. See Floating portals.

Accessibility

  • The overlay carries role="tooltip" and is named by contentDescription when you supply one, otherwise by text and metadata joined. With custom content, supply contentDescription yourself — there is no text to fall back to.
  • A tooltip presented through useTooltip or Tooltip is also a polite live region, so it is announced when it appears.
  • A tooltip is supplemental. The anchor still needs its own accessible name; ariaLabel on an icon-only control is not optional just because a tooltip exists.
  • Only a focusable tooltip is reachable by keyboard. A plain text tooltip is never a place to put a control.
  • Use FOCUSED or DWELL to name icon-only controls.
  • Use DISABLED_CLICK to explain why a control is unavailable.
  • Keep the text to a few words and put a value or unit in metadata.
  • Keep the anchor mounted for the whole life of the tooltip.
  • Use update for a value that changes while the tooltip stays up.
  • Set tooltipFocusable on the control when the tooltip hosts something interactive, such as a VerticalMenu — that path is the one that adds Escape and back dismissal and returns focus to the anchor. isFocusable on Tooltip and useTooltip only lets the overlay take pointer events; dismissal is still yours to drive there.

Avoid

  • Avoid repeating a label that is already visible next to the control.
  • Avoid hiding essential instructions in a tooltip.
  • Avoid making a plain text tooltip interactive.
  • Use the anchor and placement APIs instead of fixed viewport coordinates or a manual portal. This preserves bounds, clipping, and anchor tracking.
  • Avoid leaving tracksAnchorScale on outside an anchor animation — it re-measures every frame.
  • Avoid leaving ALWAYS on a control in a dense layout — it will cover its neighbours.