FUNSTACK UI

HomeWhyGetting startedConceptsComponentsRoadmap
GitHub

FUNSTACK UI is in beta. Part of the FUNSTACK family with FUNSTACK Router and FUNSTACK Static, which build this site.

Introduction

  • Why FUNSTACK UI
  • Overview
  • Getting started

Concepts

  • Action props
  • Pending & optimistic state
  • Transitions & ViewTransition
  • Suspense
  • Browser-owned state
  • Server Components

Guides

  • Replacing the element (render)
  • Direction and locales
  • Experimental features
  • Next.js App Router
  • React Router framework mode
  • Content Security Policy
  • Using with AI agents

Components

  • Buttons
    • Button
    • Toggle
    • ToggleGroup
    • Toolbar
  • Disclosure
    • Tabs
    • Accordion
    • Collapsible
    • NavigationMenu
  • Overlays
    • Tooltip
    • HoverCard
    • Popover
    • Dialog
    • AlertDialog
    • Drawer
    • Menu
    • Context menu (Menu)
    • Menubar (Menu)
    • Toast
  • Forms
    • Field and Form
    • Checkbox
    • CheckboxGroup
    • RadioGroup
    • Switch
    • Select
    • Combobox
    • MultiSelect
    • Slider
    • NumberField
    • OTPField
    • TextField
  • Output
    • Progress
    • Meter
    • Avatar
  • Layout
    • Separator
    • Scroll areas (recipe)

Resources

  • Roadmap & changelog
  • GitHub ↗

Tooltip

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.

Bold
Italic
Saves the document (Ctrl+S)
interestfor + popover="hint"
Show code
TooltipToolbar.tsx
// 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=&quot;hint&quot;
        </Tooltip.Popup>
      </Tooltip.Root>
    </div>
  );
}
tooltip.css
/* 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.

Async and platform behaviour: Transition types · Optimistic and pending · Suspense · Browser-owned state · Before hydration

Anatomy

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.
  • Render the Popup immediately after the Trigger. The HTML spec recommends that reading order for popovers, and some screen readers attach an adjacent tooltip to the wrong control otherwise.
  • Inside running text, render a <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).
  • One Trigger per Root.
  • 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).

How it works

Skip-delay

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.

  • No provider, no prop. The condition is read from the page when a hover or focus starts, so it works across React roots, in Server Components with nothing around them, and with tooltips that are not FUNSTACK's (any popover with role="tooltip" counts). There is no opt-out.
  • The window is "while the previous tooltip is still showing", its 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.
  • On the native path (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.
  • Skip the entry animation of an open like that with 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; }

Two mechanisms

FlagsChromiumFirefoxSafari
nonemanual popover + JSsamesame
experimental_hinthint popover: native light dismiss, JS still attachedsame as Chromiumhint unknown: behaves as manual + JS
experimental_interestFornative Trigger, no JS interaction listenersattribute ignored, JS pathattribute ignored, JS path
bothfully native, works before hydrationas experimental_hintas 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.

Props

Tooltip.Root

PropTypeDefaultDescription
delaynumber250Milliseconds 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).
closeDelaynumber150Milliseconds from leaving (Trigger and popup) or blur to close (Chromium's interest-delay-end).
disabledbooleanfalseThe 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.
childrenReactNode | ((state: TooltipRootState) => ReactNode)–The Trigger and the Popup.
State
TooltipRootState is { disabled }.
Owned
none: the Root renders no element (no ref, className or style), and no open, defaultOpen or action (see Browser-owned state).

Tooltip.Trigger

PropTypeDefaultDescription
experimental_interestForbooleanfalseRenders 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).
classNamestring | ((state: TooltipTriggerState) => string | undefined)–A class name, or a function of the part's state.
styleCSSProperties | ((state: TooltipTriggerState) => CSSProperties | undefined)–Inline style, or a function of the part's state.
childrenReactNode | ((state: TooltipTriggerState) => ReactNode)–Content, or a function of the part's state.
renderReactElement | ((props, state: TooltipTriggerState) => ReactNode)–Replace the default <button> (element form) or take over rendering (function form).
State
TooltipTriggerState is { disabled }.
Owned
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

PropTypeDefaultDescription
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_hintbooleanfalseRenders 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.
classNamestring | ((state: TooltipPopupState) => string | undefined)–A class name, or a function of the part's state.
styleCSSProperties | ((state: TooltipPopupState) => CSSProperties | undefined)–Inline style, or a function of the part's state.
childrenReactNode | ((state: TooltipPopupState) => ReactNode)–Rendered at mount (hidden), not at open time. Keep it static and non-interactive.
renderReactElement | ((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).
State
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}).
Owned
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

PropTypeDefaultDescription
classNamestring | ((state: TooltipArrowState) => string | undefined)–A class name, or a function of the part's state.
styleCSSProperties | ((state: TooltipArrowState) => CSSProperties | undefined)–Inline style, or a function of the part's state.
childrenReactNode | ((state: TooltipArrowState) => ReactNode)–Content, or a function of the part's state.
renderReactElement | ((props, state: TooltipArrowState) => ReactNode)–Replace the default <span> (element form) or take over rendering (function form).
State
TooltipArrowState is { side, align }, the Popup's values (resolved while shown).
Owned
aria-hidden, and data-side / data-align unless the Popup's side is null.

Render it inside Tooltip.Popup.

Data attributes

AttributeOnMeaning
:popover-openPopupThe tooltip is showing.
data-sidePopup, ArrowWhile 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-alignPopup, ArrowWhile shown: the resolved alignment. Otherwise the requested one. Absent with side={null}.
data-instantPopupWhile 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-disabledTrigger, PopupThe Root's disabled prop.
data-fsui-tooltip-triggerTriggerWith 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.

Keyboard and ARIA

KeyWhereBehaviour
HoverTriggerOpens 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 leavesTrigger and PopupCloses after closeDelay.
Keyboard focusTriggerOpens after delay, or at once while another tooltip is showing (focus from a click does not open).
BlurTriggerCloses after closeDelay.
EscapeanywhereCloses, 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 pressanywhereCloses (outside, on the Trigger, on the Popup). It reopens only after the pointer leaves and re-enters, or focus leaves and returns.
TouchTriggerNever opens on the JS path (no hover). Chromium's native path offers long-press.
  • The popup has 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.
  • The Trigger must be focusable. A natively disabled button never shows a tooltip; use aria-disabled="true" on a control that needs one.
  • Tooltips must not contain interactive content. For a rich preview with links and buttons, use a HoverCard; for content the user works in, a dialog or popover.
  • Do not put the only copy of important information in a tooltip: touch users may never see it.

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.

Transition types

Concept: Transitions & ViewTransition

None: Tooltip makes no transitions and has no transition prop. Animate the popup in CSS on :popover-open.

Optimistic and pending

Concept: Pending & optimistic state

None: no optimistic state and no data-pending.

Suspense

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.

Browser-owned state

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.

Before hydration

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.

Recipes

Arrow

Points at its trigger after a flip too
Beside the trigger, in reading direction
محاذاة إلى البداية
Show code
TooltipArrow.tsx
// 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.css
/* 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); }

A link Trigger

<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.

Another library part as the Trigger

<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.

  • Put the Toggle's or Item's props on the 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.
  • A disabled Toggle or Item outside a Toolbar is natively disabled and shows no tooltip. Inside a Toolbar it is 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>

Placement entirely in CSS

<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.

Async content

The popup's content renders when the tooltip mounts, not when it opens. If it must suspend, put the <Suspense> boundary inside Tooltip.Popup; a boundary above the Root would hide the Trigger too.

Browser notes

Right-to-left

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).

Firefox and RTL containers

Firefox misplaces any anchored popover along the inline axis when its parent box has a different direction from the page (an RTL island in an LTR page, or the reverse), with physical keywords too (Mozilla bug 2019601, tracked in #89). Page-level RTL is fine. The library ships no workaround.