TooltipContainer

Updated: Sep 24, 2026
TooltipContainer is the surface a tooltip is painted on: a pill-shaped, smooth-cornered plate with an optional pointer tail, sized to its own content. It is presentation only — it has no visibility state, no focus behaviour, and no anchoring logic of its own.
Tooltip already renders one for you whenever you pass text or metadata, so most applications never import it. Use it directly when you are building custom tooltip content and want that content to sit on the same surface as an ordinary tooltip, with the material handled for you.

Usage

Render it as the content of a tooltip and let the presenting layer position it. Custom content has no text for the tooltip to derive a name from, so name it with contentDescription.
import { useRef } from 'react';
import { Tooltip, TooltipContainer } from '@wearables-ui-toolkit/mrbd';

export function BatteryHint({ level }: { level: string }) {
  const anchorRef = useRef<HTMLDivElement>(null);

  return (
    <div ref={anchorRef}>
      <Tooltip
        anchorRef={anchorRef}
        isVisible
        contentDescription={`Battery ${level}`}
        content={
          <TooltipContainer
            icon={batteryIcon}
            text="Battery"
            metadata={level}
            showTooltipTail={false}
          />
        }
      />
    </div>
  );
}
Standing on its own — for example inside a coach-mark composition you already position — it needs nothing but content:
<TooltipContainer text="Swipe to dismiss" />
To draw a tail outside the tooltip layer you must supply the direction and, usually, the horizontal position yourself:
<TooltipContainer
  text="Start here"
  tailDirection="down"
  tailCenterX={tailCenterX}
/>

Props

The full prop type is TooltipContainerProps. The component takes only the props below — it accepts no children and does not spread arbitrary DOM attributes onto its root. It forwards a ref to that root element.
PropTypeDefaultDescription
text
string
—
Primary text. Clamps to two lines and ellipsizes.
metadata
string
—
Secondary text after the primary text. Stays on one line.
icon
IconSource
—
Leading icon.
trailingIcon
IconSource
—
Trailing icon.
showTooltipTail
boolean
true
Whether the pointer tail may be drawn. A tail also requires tailDirection.
tailDirection
'up' \| 'down'
—
Which way the tail points: 'up' when the surface sits below what it points at, 'down' when it sits above. Omit for a plain pill.
tailCenterX
number
Centre of the surface
Horizontal position of the tail, in CSS pixels from the surface’s left edge. Clamped so the tail stays on the straight part of the edge.
width
number \| string
Measured content width
Fixes the surface width.
height
number \| string
Measured content height
Fixes the surface height.
style
CSSProperties
{}
Extra inline styles, merged after the component’s own layout styles.
className
string
''
Extra class on the root element.
icon and trailingIcon accept any IconSource. The component owns their size and tint.

Types and enums

Tail direction

tailDirection is the union 'up' | 'down', and nothing else is accepted. 'up' draws the tail on the top edge, for a surface sitting below what it points at; 'down' draws it on the bottom edge, for a surface sitting above. Omitting the prop is how you get a tail-less pill — there is no “none” value.

Behavior

  • Shape. The surface is a single smooth-cornered path — fully rounded ends plus the tail when one is drawn — filled with --uit-color-background-elevation3 and lifted by a drop shadow. See Smooth corners.
  • Foreground blending. Text uses the uit-text-meta2 appearance with --uit-color-text-secondary, and icons use --uit-color-icon-secondary. Both composite with a lighten blend, which is how foreground content keeps its contrast on the additive-light display. If you build matching content of your own, apply the uit-color-text-secondary and uit-color-icon-secondary utility classes rather than the colour variables alone — the classes carry the required blend as well as the token.
  • Sizing. The surface is intrinsically sized: it measures itself and grows to fit its content, down to a component-owned minimum width, and re-measures when the content, the tail, or an explicit size changes. Pass width or height only when an external layout genuinely requires a fixed box.
  • Content order. Leading icon, primary text, metadata, trailing icon, laid out in a single centred row. Each part is omitted entirely when its prop is unset, and the gaps between them collapse with it.
  • Tail geometry. The tail is drawn only when showTooltipTail is true andtailDirection is set. Its footprint is reserved in the layout on the corresponding edge, so turning the tail on does not shift the text. tailCenterX is clamped to keep the tail clear of the rounded ends, and a very narrow surface falls back to a simpler tail that still leans toward the requested position. tailDirection and tailCenterX are computed for you when Tooltip renders the surface itself — that is, when you gave it text or metadata rather than content — and when the surface is a control’s tooltipContent. A TooltipContainer handed to Tooltip or useTooltip as content is rendered untouched, so there it only has a tail if you set tailDirection yourself.
  • Non-interactive. There is no focus, press, or disabled state, no role, and no pointer handling. Anything interactive belongs in a VerticalMenu or a ContextMenu presented as tooltip content instead.

Accessibility

  • The component supplies no role and no accessible name. When it is presented by Tooltip, the presenting overlay contributes role="tooltip" and the accessible name — but with custom content it cannot derive a name, so set contentDescription on the tooltip yourself.
  • Standing on its own it is just decorated text, so it needs whatever role and name its surrounding composition requires.
  • Icons inside it are decorative. Any meaning an icon carries must also be in text, metadata, or the tooltip’s contentDescription.
  • Two lines is the visible limit for text; anything longer is clipped and will not be readable even though it is still in the accessibility tree.
  • Let Tooltip own visibility and placement, and let it compute tailDirection and tailCenterX by passing it text or metadata rather than assembling the surface yourself.
  • Keep the content to a few words so the two-line clamp is never reached.
  • Turn the tail off with showTooltipTail={false} for a surface that is not pointing at anything.
  • Put the changing part of the string in metadata so the primary text stays stable and the surface does not resize on every update.

Avoid

  • Avoid using it as a general-purpose plate for page content — use StaticContainer or Surface.
  • Use an anchor instead of fixed viewport coordinates. The tooltip layer owns placement and keeps the surface aligned with its target.
  • Let the component determine width and height, and shorten text that does not fit within the two-line limit.
  • Avoid setting tailDirection on a surface that is not adjacent to what it points at — the tail will aim at nothing.
  • Use the component-owned fill, radius, and blend modes. Internal elements and generated class names are not supported customization surfaces.