The WAI-ARIA Tooltip pattern on the platform: the popup lives in the top layer (Popover API), is placed with CSS Anchor Positioning and animates with @starting-style. The library's JavaScript is a thin shim for hover and focus that steps aside where the browser can do the job.
// No "use client": this file is a Server Component. Tooltip has no action props, so every prop
// is serialisable and a Server Component renders it directly.
import { Tooltip } from "@funstack/ui/tooltip";
function BoldIcon() {
return (
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16">
<path
d="M4 2h5a3 3 0 0 1 2.1 5.1A3.3 3.3 0 0 1 9.5 14H4V2Zm2 2v3h3a1.5 1.5 0 0 0 0-3H6Zm0 5v3h3.5a1.5 1.5 0 0 0 0-3H6Z"
fill="currentColor"
/>
</svg>
);
}
function ItalicIcon() {
return (
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16">
<path d="M6 2h7v2h-2.6l-2.3 8H10v2H3v-2h2.6l2.3-8H6V2Z" fill="currentColor" />
</svg>
);
}
export function TooltipToolbar() {
return (
<div className="demo-row">
<div className="demo-toolbar" role="toolbar" aria-label="Formatting">
{/* Icon-only buttons: the tooltip text is the button's name (aria-labelledby). */}
<Tooltip.Root provides="name">
<Tooltip.Trigger className="demo-icon-button">
<BoldIcon />
</Tooltip.Trigger>
<Tooltip.Popup className="demo-tip">Bold</Tooltip.Popup>
</Tooltip.Root>
<Tooltip.Root provides="name">
<Tooltip.Trigger className="demo-icon-button">
<ItalicIcon />
</Tooltip.Trigger>
<Tooltip.Popup className="demo-tip">Italic</Tooltip.Popup>
</Tooltip.Root>
</div>
{/* A button with its own text: the tooltip is a description (aria-describedby). */}
<Tooltip.Root>
<Tooltip.Trigger className="demo-button">Save</Tooltip.Trigger>
<Tooltip.Popup className="demo-tip" side="bottom" align="start">
Saves the document (Ctrl+S)
</Tooltip.Popup>
</Tooltip.Root>
{/* Chromium: the browser owns hover, focus and dismissal. Elsewhere: the JS path. */}
<Tooltip.Root delay={400}>
<Tooltip.Trigger className="demo-button" experimental_interestFor>
Native where supported
</Tooltip.Trigger>
<Tooltip.Popup className="demo-tip" side="right" experimental_hint>
interestfor + popover="hint"
</Tooltip.Popup>
</Tooltip.Root>
</div>
);
}/* Tooltip: open state belongs to the browser, so style it with :popover-open and animate it
with @starting-style. The library ships no CSS. */
.demo-tip {
margin: 6px; /* gap from the trigger; overrides the UA's margin: auto */
padding: 4px 8px;
border: 0;
border-radius: 4px;
background: var(--color-text);
color: var(--color-bg);
font-size: 0.875rem;
max-inline-size: 24rem;
opacity: 0;
translate: 0 4px;
transition:
opacity 120ms,
translate 120ms,
display 120ms allow-discrete,
overlay 120ms allow-discrete;
}
.demo-tip:popover-open {
opacity: 1;
translate: 0 0;
@starting-style {
opacity: 0;
translate: 0 4px;
}
}
/* A warm open (another tooltip was showing, skip-delay): no entry animation. */
.demo-tip[data-instant] {
transition: none;
}
@media (prefers-reduced-motion: reduce) {
.demo-tip {
transition: none;
}
}
/* Tooltip.Arrow draws nothing itself. data-side is the side the browser placed the popup on
(after a flip too), so these rules keep the arrow on the edge that faces the trigger. */
.demo-tip-arrowed {
margin: 8px; /* symmetric: a flip swaps the popup's margins, so one-sided gaps end up outside */
overflow: visible;
}
.demo-tip-arrow {
position: absolute;
inline-size: 8px;
block-size: 8px;
background: inherit;
rotate: 45deg;
}
.demo-tip-arrow[data-side="top"] {
bottom: -4px;
inset-inline-start: calc(50% - 4px);
}
.demo-tip-arrow[data-side="bottom"] {
top: -4px;
inset-inline-start: calc(50% - 4px);
}
.demo-tip-arrow[data-side="left"] {
right: -4px;
top: calc(50% - 4px);
}
.demo-tip-arrow[data-side="right"] {
left: -4px;
top: calc(50% - 4px);
}
/* data-align is inline-relative on a top / bottom side: logical insets keep it right in RTL. */
.demo-tip-arrow[data-side="top"][data-align="start"],
.demo-tip-arrow[data-side="bottom"][data-align="start"] {
inset-inline-start: 12px;
}
.demo-tip-arrow[data-side="top"][data-align="end"],
.demo-tip-arrow[data-side="bottom"][data-align="end"] {
inset-inline-start: auto;
inset-inline-end: 12px;
}
.demo-toolbar {
display: inline-flex;
gap: 4px;
padding: 4px;
border: 1px solid var(--color-border);
border-radius: 6px;
}
.demo-icon-button {
display: inline-grid;
place-items: center;
inline-size: 2rem;
block-size: 2rem;
border: 1px solid var(--color-border);
border-radius: 4px;
background: var(--color-bg);
color: var(--color-text);
cursor: pointer;
}
/* The trigger whose tooltip is open: the popup is the next sibling. */
.demo-icon-button:has(+ .demo-tip:popover-open),
.demo-button:has(+ .demo-tip:popover-open) {
border-color: var(--color-primary);
}Hover a button, or move focus to it with the keyboard. Escape, or any click, closes the tooltip. This example is a Server Component.
import { Tooltip } from "@funstack/ui/tooltip";
<Tooltip.Root> {/* no DOM: id, options, interaction */}
<Tooltip.Trigger>Save</Tooltip.Trigger> {/* button */}
<Tooltip.Popup> {/* div[popover][role=tooltip] */}
Saves the document (Ctrl+S)
<Tooltip.Arrow /> {/* optional: span[aria-hidden] */}
</Tooltip.Popup>
</Tooltip.Root><button type="button" aria-describedby="_r_1_">Save</button>
<div id="_r_1_" popover="manual" role="tooltip" data-side="top" data-align="center"
style="position-area: top; position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline">
Saves the document (Ctrl+S)
<span aria-hidden="true" data-side="top" data-align="center"></span>
</div>Root renders no DOM, so the Trigger stays a direct child of your toolbar or flex row. There is no Portal and no Positioner: the top layer and anchor positioning do those jobs.<span> Popup: render={<span />}. The default <div> cannot sit inside a <p>: the HTML parser closes the paragraph before it, so server-rendered HTML no longer matches React's tree and hydration fails (React also warns in development). The <span> keeps popover and role="tooltip"; keep its content phrasing content (text, kbd, span).Arrow is optional and draws nothing itself: it carries the Popup's data-side / data-align, which are where the browser placed the popup (see Arrow).Once one tooltip is showing, the next one appears at once, as on every desktop platform: moving the pointer along a toolbar, or arrowing through it, shows each tooltip without waiting. The rule is global to the page, and there is nothing to set up:
A tooltip opens with no delay while any [role="tooltip"]:popover-open exists in the document, and the tooltip that was showing is hidden at once.
role="tooltip" counts). There is no opt-out.closeDelay included (150 ms by default), which covers moving between adjacent controls. After both have closed, the next tooltip waits its delay again; there is no longer cooldown.experimental_interestFor in Chromium) the browser reads the delay from the Trigger's computed style, so the Trigger renders interest-delay-start: calc(250ms * (1 - var(--fsui-tooltip-warm, 0))) and a small stylesheet that sets --fsui-tooltip-warm to 1 on marked Triggers while a tooltip is showing. React hoists it into <head> (during server rendering too); it works before hydration. Nothing visual: it times the interaction only. Under a strict style-src it needs its hash or a nonce (Content Security Policy). Without it (blocked, or React dropped it), the var() falls back to 0: each tooltip opens after its own delay, and only skip-delay is lost.data-instant: the Popup carries it while it is shown by an open that began while another [role="tooltip"]:popover-open existed, so .tip[data-instant] { transition: none; } (or animation: none for a keyframe entry) makes browsing a toolbar instant while the first tooltip still fades in. The library writes it from the popup's beforetoggle event, on both paths, before the open's first frame, so no transition starts; it is removed when the tooltip closes, so every exit animates as usual. It is a DOM attribute only (no state field), and like the skip itself it counts any role="tooltip" popover. Before hydration, on the native path, a warm open still opens at once but has no data-instant, so its animation plays. CSS alone cannot express it: by the time the new tooltip is :popover-open the previous one is already hidden, and a :has(:popover-open) condition matches the opening tooltip itself./* The library's rule (rendered by a Trigger with experimental_interestFor): */
@property --fsui-tooltip-warm { syntax: "<number>"; inherits: false; initial-value: 0; }
:root:has([role="tooltip"]:popover-open) [data-fsui-tooltip-trigger] { --fsui-tooltip-warm: 1; }| Flags | Chromium | Firefox | Safari |
|---|---|---|---|
| none | manual popover + JS | same | same |
experimental_hint | hint popover: native light dismiss, JS still attached | same as Chromium | hint unknown: behaves as manual + JS |
experimental_interestFor | native Trigger, no JS interaction listeners | attribute ignored, JS path | attribute ignored, JS path |
| both | fully native, works before hydration | as experimental_hint | as no flags |
<Tooltip.Root provides="name">
<Tooltip.Trigger experimental_interestFor className="icon-button">
<SaveIcon />
</Tooltip.Trigger>
<Tooltip.Popup experimental_hint className="tip">Save</Tooltip.Popup>
</Tooltip.Root>The baseline popover type is manual, not auto, so that opening a tooltip never closes an open menu or listbox.
Tooltip.Root| Prop | Type | Default | Description |
|---|---|---|---|
delay | number | 250 | Milliseconds from hover or keyboard focus to open (Chromium's interest-delay-start). Hover and focus share it. Skipped while another tooltip is showing (see Skip-delay). |
closeDelay | number | 150 | Milliseconds from leaving (Trigger and popup) or blur to close (Chromium's interest-delay-end). |
disabled | boolean | false | The tooltip never opens. The ARIA relation stays in place. |
provides | "description" | "name" | "description" | Which relation the tooltip provides for the Trigger. "description": aria-describedby, for Triggers with their own name. "name": aria-labelledby, for icon-only Triggers; do not also set aria-label. |
children | ReactNode | ((state: TooltipRootState) => ReactNode) | – | The Trigger and the Popup. |
TooltipRootState is { disabled }.ref, className or style), and no open, defaultOpen or action (see Browser-owned state).Tooltip.Trigger| Prop | Type | Default | Description |
|---|---|---|---|
experimental_interestFor | boolean | false | Renders interestfor and interest-delay-start/end so the browser owns hover, focus, Escape and long-press. Where the element implements interestForElement (Chromium), the library attaches no interaction listeners (only a passive beforetoggle that writes data-instant); elsewhere the attribute is ignored and the JS path runs. Pair with Popup experimental_hint. Also renders the data-fsui-tooltip-trigger marker and the skip-delay stylesheet (see Skip-delay). |
className | string | ((state: TooltipTriggerState) => string | undefined) | – | A class name, or a function of the part's state. |
style | CSSProperties | ((state: TooltipTriggerState) => CSSProperties | undefined) | – | Inline style, or a function of the part's state. |
children | ReactNode | ((state: TooltipTriggerState) => ReactNode) | – | Content, or a function of the part's state. |
render | ReactElement | ((props, state: TooltipTriggerState) => ReactNode) | – | Replace the default <button> (element form) or take over rendering (function form). |
TooltipTriggerState is { disabled }.aria-describedby (with provides="description") or aria-labelledby (with provides="name"), both token-merged with your ids; data-disabled; and interestfor, the interest-delay-* style and data-fsui-tooltip-trigger with experimental_interestFor.Every <button> prop passes through, including onClick and type (default "button"): the library attaches its listeners with addEventListener.
Tooltip.Popup| Prop | Type | Default | Description |
|---|---|---|---|
side | "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end" | null | "top" | Placement through inline position-area, with position-try-fallbacks flipping it when it does not fit. "inline-start" / "inline-end" follow the popup's direction (inline-end is the right in LTR, the left in RTL); the other four are physical. null emits no inline positioning and no data-side / data-align, so your stylesheet owns placement. |
align | "start" | "center" | "end" | "center" | Alignment along the side. On a top / bottom side, start / end are inline-relative (start lines up the inline-start edges: the left in LTR, the right in RTL); on the other sides they are the top / bottom edges. Ignored when side is null. |
experimental_hint | boolean | false | Renders popover="hint" instead of "manual": native light dismiss, and the tooltip can open over an open menu without closing it. Engines that do not know hint treat it as manual, and the JS Escape and click handling stays. |
className | string | ((state: TooltipPopupState) => string | undefined) | – | A class name, or a function of the part's state. |
style | CSSProperties | ((state: TooltipPopupState) => CSSProperties | undefined) | – | Inline style, or a function of the part's state. |
children | ReactNode | ((state: TooltipPopupState) => ReactNode) | – | Rendered at mount (hidden), not at open time. Keep it static and non-interactive. |
render | ReactElement | ((props, state: TooltipPopupState) => ReactNode) | – | Replace the default <div> (element form) or take over rendering (function form). A <span> for a tooltip inside running text (phrasing content only). |
TooltipPopupState is { disabled, side, align }; while the tooltip is shown, side and align are where the browser placed it (a physical side, after any fallback flip); otherwise they are your props (side is null with side={null}).id, popover, role ("tooltip"), data-disabled, and data-side / data-align unless side is null.Your style wins over the inline placement, so style={{ positionArea: "bottom span-right" }} works for a one-off; data-side then reports where that put it. data-instant is not a prop: the Root writes it on the DOM for a warm open (see Skip-delay).
Tooltip.Arrow| Prop | Type | Default | Description |
|---|---|---|---|
className | string | ((state: TooltipArrowState) => string | undefined) | – | A class name, or a function of the part's state. |
style | CSSProperties | ((state: TooltipArrowState) => CSSProperties | undefined) | – | Inline style, or a function of the part's state. |
children | ReactNode | ((state: TooltipArrowState) => ReactNode) | – | Content, or a function of the part's state. |
render | ReactElement | ((props, state: TooltipArrowState) => ReactNode) | – | Replace the default <span> (element form) or take over rendering (function form). |
TooltipArrowState is { side, align }, the Popup's values (resolved while shown).aria-hidden, and data-side / data-align unless the Popup's side is null.Render it inside Tooltip.Popup.
| Attribute | On | Meaning |
|---|---|---|
:popover-open | Popup | The tooltip is showing. |
data-side | Popup, Arrow | While shown: the side the browser placed the popup on (top / bottom / left / right, after any flip). Otherwise the requested side. Absent with side={null}. |
data-align | Popup, Arrow | While shown: the resolved alignment. Otherwise the requested one. Absent with side={null}. |
data-instant | Popup | While shown by an open that began while another tooltip was showing (a skip-delay open; see Skip-delay). Written by the library from the popup's beforetoggle, before the open's first frame; removed when it closes. No state counterpart. |
data-disabled | Trigger, Popup | The Root's disabled prop. |
data-fsui-tooltip-trigger | Trigger | With experimental_interestFor only: what the skip-delay stylesheet matches. Not a styling hook. |
data-side is where the popup is: the library reads which position-try-fallbacks option the browser applied from the popup's computed position-area when it opens, on scroll and on resize. The browser still does the placing. With a physical side, a tooltip that opens where you asked costs no React render; a logical one (inline-start / inline-end) costs one render on show and one on hide, since data-side turns physical while shown. The inline position-area stays your request. Two caveats: an entry animation keyed on data-side with @starting-style starts from the requested side on a flipped open (key it on opacity or a fixed offset, as below), and a gap written as a one-sided margin on [data-side] lands on the wrong edge after a flip, because the flip swaps the popup's margins too. Either put a static margin on the requested edge (not keyed on data-side; the flip moves it to the other edge), or key a margin on both sides of the axis on data-side, including the closed inline-start / inline-end values so the first layout has it.
| Key | Where | Behaviour |
|---|---|---|
| Hover | Trigger | Opens after delay, or at once while another tooltip is showing (which then closes). Stays open while the pointer is over the Trigger or the Popup. |
| Pointer leaves | Trigger and Popup | Closes after closeDelay. |
| Keyboard focus | Trigger | Opens after delay, or at once while another tooltip is showing (focus from a click does not open). |
| Blur | Trigger | Closes after closeDelay. |
| Escape | anywhere | Closes, wherever focus is; focus stays on the Trigger. Only this tooltip closes: an enclosing Dialog, Menu or toast stays open for the next Escape. A preventDefault() on the Escape keeps it open; stopPropagation() does not, and inside a modal Dialog it makes the dialog close on the same Escape (the browser closes it before the library can claim the key). Before the tooltip shows, Escape on the Trigger cancels the coming open. |
| Pointer press | anywhere | Closes (outside, on the Trigger, on the Popup). It reopens only after the pointer leaves and re-enters, or focus leaves and returns. |
| Touch | Trigger | Never opens on the JS path (no hover). Chromium's native path offers long-press. |
role="tooltip"; the Trigger gets aria-describedby or aria-labelledby per provides, and no aria-expanded. The relation works while the popup is hidden, so screen readers announce the text on focus in every engine.disabled button never shows a tooltip; use aria-disabled="true" on a control that needs one.In development, the library warns when provides="name" is combined with an aria-label, when the Trigger is not focusable, and when the popup contains focusable content.
Concept: Transitions & ViewTransition
None: Tooltip makes no transitions and has no transition prop. Animate the popup in CSS on :popover-open.
Concept: Pending & optimistic state
None: no optimistic state and no data-pending.
Concept: Suspense
The popup's content renders when the tooltip mounts, not when it opens. If it must suspend, put the <Suspense> boundary inside Tooltip.Popup.
Concept: Browser-owned state
All of it: a tooltip's visibility is not application state, so the browser owns it.
There is no open prop, no callback and no data-open: every open and close is the browser's or a timer the user drives, so none of it is a request (an action). The popup is a popover in the top layer, opened and closed by the browser (or by the library's listeners calling showPopover / hidePopover), never through React state. Style it with :popover-open, and the Trigger of an open tooltip with :has(+ :popover-open). Tooltip is therefore the one component with no transitions, no data-pending and no transition prop; animate it in CSS:
.tip {
opacity: 0;
translate: 0 4px;
transition: opacity 120ms, translate 120ms, display 120ms allow-discrete, overlay 120ms allow-discrete;
}
.tip:popover-open {
opacity: 1;
translate: 0 0;
@starting-style { opacity: 0; translate: 0 4px; }
}
.tip[data-instant] {
transition: none; /* a warm open (another tooltip was showing): no entry animation */
}
@media (prefers-reduced-motion: reduce) {
.tip { transition: none; }
}To observe opens (for analytics), listen to the popup's native toggle event through a ref.
Concept: Server Components
With experimental_interestFor and experimental_hint in Chromium, the whole tooltip (it is plain HTML). Elsewhere the JS path attaches at hydration. The ARIA relation is in the HTML either way.
// No "use client": a Server Component, like the toolbar example. Tooltip.Arrow is a client part
// that only reads its Popup's placement, so it renders from here as is.
import { Tooltip } from "@funstack/ui/tooltip";
export function TooltipArrow() {
return (
<div className="demo-row">
{/* Asked for the top: near the top of the window the browser flips it below, and the
arrow follows (data-side is the side the browser chose). */}
<Tooltip.Root>
<Tooltip.Trigger className="demo-button">Above, or below</Tooltip.Trigger>
<Tooltip.Popup className="demo-tip demo-tip-arrowed">
Points at its trigger after a flip too
<Tooltip.Arrow className="demo-tip-arrow" />
</Tooltip.Popup>
</Tooltip.Root>
{/* inline-end: the right of the trigger here, its left in a right-to-left page. */}
<Tooltip.Root>
<Tooltip.Trigger className="demo-button">Inline end</Tooltip.Trigger>
<Tooltip.Popup className="demo-tip demo-tip-arrowed" side="inline-end">
Beside the trigger, in reading direction
<Tooltip.Arrow className="demo-tip-arrow" />
</Tooltip.Popup>
</Tooltip.Root>
{/* The same in a right-to-left container: align="start" lines up the right edges. */}
<div dir="rtl" className="demo-row">
<Tooltip.Root>
<Tooltip.Trigger className="demo-button">بداية</Tooltip.Trigger>
<Tooltip.Popup className="demo-tip demo-tip-arrowed" side="bottom" align="start">
محاذاة إلى البداية
<Tooltip.Arrow className="demo-tip-arrow" />
</Tooltip.Popup>
</Tooltip.Root>
</div>
</div>
);
}/* Tooltip: open state belongs to the browser, so style it with :popover-open and animate it
with @starting-style. The library ships no CSS. */
.demo-tip {
margin: 6px; /* gap from the trigger; overrides the UA's margin: auto */
padding: 4px 8px;
border: 0;
border-radius: 4px;
background: var(--color-text);
color: var(--color-bg);
font-size: 0.875rem;
max-inline-size: 24rem;
opacity: 0;
translate: 0 4px;
transition:
opacity 120ms,
translate 120ms,
display 120ms allow-discrete,
overlay 120ms allow-discrete;
}
.demo-tip:popover-open {
opacity: 1;
translate: 0 0;
@starting-style {
opacity: 0;
translate: 0 4px;
}
}
/* A warm open (another tooltip was showing, skip-delay): no entry animation. */
.demo-tip[data-instant] {
transition: none;
}
@media (prefers-reduced-motion: reduce) {
.demo-tip {
transition: none;
}
}
/* Tooltip.Arrow draws nothing itself. data-side is the side the browser placed the popup on
(after a flip too), so these rules keep the arrow on the edge that faces the trigger. */
.demo-tip-arrowed {
margin: 8px; /* symmetric: a flip swaps the popup's margins, so one-sided gaps end up outside */
overflow: visible;
}
.demo-tip-arrow {
position: absolute;
inline-size: 8px;
block-size: 8px;
background: inherit;
rotate: 45deg;
}
.demo-tip-arrow[data-side="top"] {
bottom: -4px;
inset-inline-start: calc(50% - 4px);
}
.demo-tip-arrow[data-side="bottom"] {
top: -4px;
inset-inline-start: calc(50% - 4px);
}
.demo-tip-arrow[data-side="left"] {
right: -4px;
top: calc(50% - 4px);
}
.demo-tip-arrow[data-side="right"] {
left: -4px;
top: calc(50% - 4px);
}
/* data-align is inline-relative on a top / bottom side: logical insets keep it right in RTL. */
.demo-tip-arrow[data-side="top"][data-align="start"],
.demo-tip-arrow[data-side="bottom"][data-align="start"] {
inset-inline-start: 12px;
}
.demo-tip-arrow[data-side="top"][data-align="end"],
.demo-tip-arrow[data-side="bottom"][data-align="end"] {
inset-inline-start: auto;
inset-inline-end: 12px;
}
.demo-toolbar {
display: inline-flex;
gap: 4px;
padding: 4px;
border: 1px solid var(--color-border);
border-radius: 6px;
}
.demo-icon-button {
display: inline-grid;
place-items: center;
inline-size: 2rem;
block-size: 2rem;
border: 1px solid var(--color-border);
border-radius: 4px;
background: var(--color-bg);
color: var(--color-text);
cursor: pointer;
}
/* The trigger whose tooltip is open: the popup is the next sibling. */
.demo-icon-button:has(+ .demo-tip:popover-open),
.demo-button:has(+ .demo-tip:popover-open) {
border-color: var(--color-primary);
}Scroll the page until the first button is near the top of the window and hover it: the browser flips the tooltip below, and the arrow, keyed on [data-side], moves to the edge that faces the button. With no Arrow element, the same CSS works on the Popup itself as a pseudo-element:
.tip::after { content: ""; position: absolute; width: 8px; height: 8px; background: inherit; rotate: 45deg; }
.tip[data-side="top"]::after { bottom: -4px; inset-inline-start: calc(50% - 4px); }
.tip[data-side="bottom"]::after { top: -4px; inset-inline-start: calc(50% - 4px); }<Tooltip.Root>
<Tooltip.Trigger render={<a href="/pricing" />}>Pricing</Tooltip.Trigger>
<Tooltip.Popup className="tip">Opens the pricing page</Tooltip.Popup>
</Tooltip.Root>The native interestfor path only applies to buttons and links; any other element (a focusable <span tabIndex={0}>) always uses the JS path.
<ToggleGroup.Root aria-label="Text style" defaultValue={["bold"]} valueChangeAction={saveStyles}>
<Tooltip.Root provides="name">
<Tooltip.Trigger render={<ToggleGroup.Item value="bold" className="tool" />}>
<BoldIcon />
</Tooltip.Trigger>
<Tooltip.Popup className="tip">Bold</Tooltip.Popup>
</Tooltip.Root>
<Tooltip.Root provides="name">
<Tooltip.Trigger render={<ToggleGroup.Item value="italic" className="tool" />}>
<ItalicIcon />
</Tooltip.Trigger>
<Tooltip.Popup className="tip">Italic</Tooltip.Popup>
</Tooltip.Root>
</ToggleGroup.Root>
<Tooltip.Root>
<Tooltip.Trigger render={<Toggle pressedChangeAction={setTrackChanges} className="tool" />}>
Track changes
</Tooltip.Trigger>
<Tooltip.Popup className="tip">Mark every edit for review</Tooltip.Popup>
</Tooltip.Root>The render element is a library part, and each part keeps its own job. Tooltip.Trigger adds only its ARIA relation (aria-labelledby or aria-describedby, token-merged) and the listeners it attaches through the ref. The ToggleGroup.Item or Toggle renders the <button> and owns what it always owns: type, aria-pressed, data-pressed, data-pending, the click and, in a group, the roving focus.
render element: value, disabled, the action, and className, which may then be a function of the Item's state. Leave className off Tooltip.Trigger: the two are joined as strings, which does not work with a function. Children may go on either.aria-disabled, so it stays focusable and its tooltip still opens.Any library part that renders a button composes the same way, because Tooltip.Trigger adds only its ARIA relation and its listeners. An overlay's Trigger is the common case: render={<Popover.Trigger />}, render={<Dialog.Trigger />} or render={<Drawer.Trigger />} gives an icon button that the tooltip names and that opens the overlay on a click. The overlay's Trigger stays inside its own Root, as usual.
<Popover.Root>
<Tooltip.Root provides="name">
<Tooltip.Trigger render={<Popover.Trigger className="icon-button" />}>
<BellIcon />
</Tooltip.Trigger>
<Tooltip.Popup className="tip">Notifications</Tooltip.Popup>
</Tooltip.Root>
<Popover.Popup className="popover">…</Popover.Popup>
</Popover.Root><Tooltip.Popup side={null} className="tip tip-beside">...</Tooltip.Popup>.tip-beside {
/* self-* keywords follow the popup's direction; plain logical ones (inline-end) would follow
the root's only, because the popup is in the top layer. */
position-area: self-x-end;
position-try-fallbacks: flip-inline;
margin-inline: 6px;
}With side={null} the library emits no data-side; it cannot read placement your own @position-try rules produce.
Nothing reads direction in JavaScript. side="inline-start" / "inline-end" and align="start" / "end" on a top or bottom side use the self-* position-area keywords, which follow the popup's own direction, inherited from where you render it: an RTL page and an RTL container (dir="rtl" on any ancestor) both mirror them, before hydration too. top / bottom / left / right stay physical. While shown, data-side is physical (inline-end reads left in RTL).