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.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>
);
}
<TooltipContainer text="Swipe to dismiss" />
<TooltipContainer
text="Start here"
tailDirection="down"
tailCenterX={tailCenterX}
/>
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.| Prop | Type | Default | Description |
|---|---|---|---|
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. |
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.--uit-color-background-elevation3 and lifted by a drop shadow. See Smooth corners.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.width or height only when an external layout genuinely requires a fixed box.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.VerticalMenu or a ContextMenu presented as tooltip content instead.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.text, metadata, or the tooltip’s contentDescription.text; anything longer is clipped and will not be readable even though it is still in the accessibility tree.Tooltip own visibility and placement, and let it compute tailDirection and tailCenterX by passing it text or metadata rather than assembling the surface yourself.showTooltipTail={false} for a surface that is not pointing at anything.metadata so the primary text stays stable and the surface does not resize on every update.StaticContainer or Surface.width and height, and shorten text that does not fit within the two-line limit.tailDirection on a surface that is not adjacent to what it points at — the tail will aim at nothing.