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 ↗

Toast

Toasts report on something that already happened or is happening elsewhere. The input is a function, toast(), callable from anywhere: an action body, a store, an effect. The output is yours: a Toast.Viewport rendered once maps the queue to parts. The queue is urgent by design: React holds every transition while an async action is pending, so a toast pushed as a transition would appear only after the action it reports on. Toast spends its Async React budget elsewhere: a toast that follows a promise, an Undo that is an ordinary action prop with data-pending, an onClose handler that knows whether the Undo window was used, and a Suspense guard so a toast whose content suspends does not blank the page.

Quarterly report.pdf
Show code
ToastArchive.tsx
"use client";
import { useState } from "react";
import { Menu } from "@funstack/ui/menu";
import { toast } from "@funstack/ui/toast";
import { fakeSave } from "./fake-api.js";

// One promise feeds both the menu item and the toast: `toast.promise` shows "Archiving…" at once
// (data-pending on the toast), swaps to the success or error toast when the fake server call
// settles, and returns a promise that settles with it, so the item stays pending exactly as long
// and the menu closes when it is done. The success toast's Undo is an action prop: pending while
// it runs, then the toast closes. With `error` given, a failure is the toast's to show: the
// returned promise resolves and nothing reaches an Error Boundary.
export function ToastArchive() {
  const [fail, setFail] = useState(false);
  return (
    <div className="demo-stack">
      <div className="demo-row">
        <span>Quarterly report.pdf</span>
        <Menu.Root>
          <Menu.Trigger className="demo-button" aria-label="Actions for Quarterly report.pdf">
            {({ pending }) => (pending ? <span className="demo-spinner" aria-hidden /> : "⋯")}
          </Menu.Trigger>
          <Menu.Popup className="demo-menu">
            <Menu.Item
              action={() =>
                toast.promise(fakeSave("the archive", { ms: 1500, fail }), {
                  pending: { title: "Archiving…" },
                  success: {
                    title: "Archived",
                    description: "Quarterly report.pdf",
                    type: "success",
                    action: {
                      label: "Undo",
                      action: () => fakeSave("the undo", { ms: 800 }),
                    },
                  },
                  error: (e) => ({
                    title: "Could not archive",
                    description: e instanceof Error ? e.message : String(e),
                    type: "error",
                    priority: "high",
                  }),
                })
              }
            >
              {({ pending }) => (pending ? "Archiving…" : "Archive")}
            </Menu.Item>
            <Menu.Item action={() => toast({ title: "Link copied" })}>Copy link</Menu.Item>
          </Menu.Popup>
        </Menu.Root>
      </div>
      <label className="demo-row">
        <input type="checkbox" checked={fail} onChange={(e) => setFail(e.target.checked)} />
        Make Archive fail
      </label>
    </div>
  );
}
toast.css
/* Toast: the Viewport is a <section popover="manual">, shown in the top layer while it has toasts
   (`:popover-open`, `data-paused`). Roots carry `data-pending`, `data-ending` and `data-type`.
   Enter with @starting-style, exit on [data-ending]: the library keeps the toast until its
   transitions finish. */

.demo-toasts {
  position: fixed;
  inset: auto 1rem 1rem auto;
  margin: 0;
  padding: 0;
  border: 0;
  inline-size: min(22rem, calc(100vw - 2rem));
  overflow: visible;
  background: transparent;
  color: var(--color-text);
  /* The region's box never blocks the page; the toasts take pointer events. */
  pointer-events: none;
}
.demo-toast-slot {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 200ms;
}
/* Collapse the gap a leaving toast leaves behind. */
.demo-toast-slot:has([data-ending]) {
  grid-template-rows: 0fr;
}
.demo-toast {
  display: flex;
  align-items: start;
  gap: 0.5rem;
  min-block-size: 0;
  overflow: hidden;
  margin-block-start: 0.5rem;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.25);
  pointer-events: auto;
  transition:
    opacity 200ms,
    translate 200ms;
}
@starting-style {
  .demo-toast {
    opacity: 0;
    translate: 0 1rem;
  }
}
.demo-toast[data-ending] {
  opacity: 0;
  translate: 0 1rem;
}
.demo-toast[data-pending] {
  cursor: progress;
}
/* `/ ""`: a decoration, kept out of the title's accessible name. */
.demo-toast[data-pending] .demo-toast-title::after {
  content: " ⏳" / "";
}
.demo-toast[data-type="success"] {
  border-inline-start: 4px solid #16a34a;
}
.demo-toast[data-type="error"] {
  border-inline-start: 4px solid #dc2626;
}
.demo-toast:focus-visible {
  outline: 2px solid var(--color-accent, #4f46e5);
  outline-offset: 2px;
}
.demo-toast-text {
  flex: 1;
}
.demo-toast-title {
  font-weight: 600;
}
.demo-toast-description {
  margin: 0.15rem 0 0;
  font-size: 0.875em;
  opacity: 0.8;
}
.demo-toast-action[data-pending] {
  cursor: progress;
  opacity: 0.7;
}
.demo-toast-close {
  border: 0;
  padding: 0 0.4em;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 1.2em;
  line-height: 1.4;
  cursor: pointer;
}
.demo-toast-queued {
  margin: 0.25rem 0 0;
  text-align: end;
  font-size: 0.8em;
  opacity: 0.8;
}
.demo-toast-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.demo-toast-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-inline-size: 20rem;
  padding: 0.25rem 0;
}
@media (prefers-reduced-motion: reduce) {
  .demo-toast,
  .demo-toast-slot {
    transition: none;
  }
}
Async and platform behaviour: Transition types · Optimistic and pending · Suspense · Browser-owned state · Before hydration

Anatomy

import { Toast, toast } from "@funstack/ui/toast";

// Once, near the root of the app (from a Client Component: children is a function).
<Toast.Viewport>                          {/* section[popover=manual][aria-label="Notifications (F8)"] */}
  {({ toasts }) =>
    toasts.map((t) => (
      <Toast.Root key={t.id} toast={t}>   {/* div[role=dialog|alertdialog][tabindex=0] */}
        <Toast.Title />                   {/* div: t.title */}
        <Toast.Description />             {/* p: t.description, nothing when absent */}
        <Toast.Action />                  {/* button: t.action, nothing when absent */}
        <Toast.Close aria-label="Close">×</Toast.Close>
      </Toast.Root>
    ))
  }
</Toast.Viewport>

// Anywhere on the client:
toast({ title: "Link copied" });

This page's Viewport, which every example on it feeds:

ToastNotifications.tsx
"use client";
import { Toast } from "@funstack/ui/toast";
import type { ToastItem } from "@funstack/ui/toast";

// The toast region, rendered once (here: once on this page; in an app, near the root). It is a
// `<section popover="manual">` in the top layer, shown while it has toasts, and moves into an
// open modal Dialog by itself. The Viewport's children map the queue to parts.
function renderToast(t: ToastItem) {
  return (
    <div className="demo-toast-slot" key={t.id}>
      <Toast.Root toast={t} className="demo-toast">
        <div className="demo-toast-text">
          <Toast.Title className="demo-toast-title" />
          <Toast.Description className="demo-toast-description" />
        </div>
        <Toast.Action className="demo-button demo-toast-action">
          {({ pending }) => (pending ? "Undoing…" : t.action?.label)}
        </Toast.Action>
        <Toast.Close className="demo-toast-close" aria-label="Close">
          ×
        </Toast.Close>
      </Toast.Root>
    </div>
  );
}

export function ToastNotifications() {
  return (
    <Toast.Viewport className="demo-toasts">
      {({ toasts, queued }) => (
        <>
          {toasts.map(renderToast)}
          {queued > 0 && <p className="demo-toast-queued">+{queued} more</p>}
        </>
      )}
    </Toast.Viewport>
  );
}
  • No Provider. toast is bound to a module-level default manager; a Viewport without manager renders it. A second Viewport on the same manager warns and renders nothing. createToastManager() makes an isolated queue (a second React root, a test) for <Toast.Viewport manager={m}>.
  • No list element, no Portal part. Toasts are focusable dialogs (alertdialog for priority: "high") named by their Title and described by their Description. The region is wherever the Viewport is rendered; its only move (into a modal dialog) is the library's. On the client it sits inside two display: contents wrappers: an anchor where the Viewport is rendered, and the element the library moves.
  • The Title is a div, not a heading: transient notifications stay out of heading navigation.
  • Calls made before the Viewport mounts are buffered and shown when it does. A Viewport that unmounts leaves its toasts with the manager for the next one (timers stop; no onClose is called).

How it works

The urgent queue

Every queue change (add, update, dismiss, the drop after an exit animation) is a normal, urgent update. toast() dispatches from a microtask, so a call inside a startTransition scope, the sync prefix of an action included, escapes the scope and shows at once; calls keep their order. What a toast drives is a transition as usual: its Action's action. The report that it left, onClose, is a handler: a fact, called synchronously and not awaited.

Show code
ToastUrgent.tsx
"use client";
import { useTransition } from "react";
import { toast } from "@funstack/ui/toast";
import { sleep } from "./fake-api.js";

// React holds every transition update while an async action is pending anywhere in the app. A
// toast pushed as a transition would therefore appear only after the action it reports on. The
// queue is urgent instead: `toast()` dispatches from a microtask, so the "Saving…" toast shows at
// once, from inside the action's own transition, while the button is still pending.
export function ToastUrgent() {
  const [pending, startTransition] = useTransition();
  return (
    <div className="demo-row">
      <button
        type="button"
        className="demo-button"
        data-pending={pending ? "" : undefined}
        onClick={() =>
          startTransition(async () => {
            const id = toast({ title: "Saving…", duration: null });
            await sleep(2000);
            toast.update(id, { title: "Saved", type: "success", duration: 3000 });
          })
        }
      >
        {pending ? "Saving (2 s)…" : "Save"}
      </button>
      <button
        type="button"
        className="demo-button"
        onClick={() => {
          for (let i = 1; i <= 5; i++) toast({ title: `Message ${i} of 5` });
        }}
      >
        Burst of five
      </button>
    </div>
  );
}

limit (default 3) toasts render at once; later ones wait in order and show as earlier ones leave. Nothing is dropped, so an Undo is never lost to a burst. state.queued counts the waiting ones. A toast() with an existing id updates that toast in place ("one toast per key").

Promise toasts

toast.promise(promise, { pending, success, error }) shows pending at once with data-pending and no timer, and replaces it with success or error (options, or functions of the value / the reason) when the promise settles: same toast, same element, announced again. It returns a promise that settles with the input in the same tick, so action={() => toast.promise(save(), …)} keeps the part that started the work pending for exactly as long.

The promiseToastReturned promise
fulfils, success givenreplaced by successresolves with the value
fulfils, no successdismissed (reason: "dismiss")resolves with the value
rejects, error givenreplaced by errorresolves with undefined: the toast is the handler
rejects, no errordismissedrejects with the reason (the action prop's Error Boundary gets it)
a success / error function throwsdismissed (never left pending)rejects with what the function threw

Undo and onClose

Toast.Action is a pure trigger, like Menu.Item. While its action runs the Action and the Root carry data-pending and the toast's timer is paused; when it resolves the toast closes with reason: "activate" (unless closeOnActivate={false}). A second click meanwhile is ignored and the Action is aria-disabled="true": one Undo, one Retry. With closeOnActivate={false} the toast stays and the Action is your own trigger, so every click runs (add whilePending="ignore" for a Retry that must not overlap). A rejection keeps the toast and reaches the nearest Error Boundary above the Action part, the part that owns the transition. Not when the Action is gone or hidden by the time it rejects: the toast was closed while the action ran, or a toast.update gave it content that is still suspending. The error then goes to the global reportError (a window error event) instead.

To show the failure in the toast, catch inside the action, update the toast and call details.reject(): the toast stays with no Error Boundary involved, data-pending leaves, the timer resumes, and the Action can be pressed again (a Retry).

toast({
  title: "Archived",
  action: {
    label: "Undo",
    action: async (details) => {
      try {
        await unarchive(itemId);
      } catch (e) {
        toast.update(details.id, { title: "Could not undo", description: String(e), priority: "high" });
        details.reject(); // keep the toast: a resolved action would close it
      }
    },
  },
});

A caught error closes the toast

A catch inside the action resolves it, and a resolved action closes the toast, so a "Could not undo" written with toast.update in the catch is never seen unless the action also calls details.reject(). Rethrowing after the update does not help: any boundary that contains the toast replaces the toast you just updated.

For an action that lets its error through, where the Error Boundary sits decides what a failed Undo takes with it:

BoundaryA failed Undo shows
around Toast.Action, inside the Rootthe fallback instead of the button; the toast, its Title and its Close stay. The recommended place.
around one Toast.Root (one per toast, in the Viewport's children function)the fallback instead of that toast; the others stay
around the list inside the Viewportone fallback instead of every toast
around Toast.Viewport, or none nearer than the app'sthe region is gone, or the page is
<Toast.Root toast={t}>
  <Toast.Title />
  <ErrorBoundary fallback={<span>Could not undo</span>}>
    <Toast.Action />
  </ErrorBoundary>
  <Toast.Close aria-label="Close">×</Toast.Close>
</Toast.Root>

A toast's onClose is called once, synchronously, in the moment the toast is closed (its exit animation, if any, has not run yet): "activate" (its Action settled), "dismiss" (Close, Escape, toast.dismiss(), a promise toast with no message for its outcome) or "timeout". That is the "do later, unless undone" pattern:

  • Groceries
  • Dentist
  • Call Ada
    Show code
    ToastUndoWindow.tsx
    "use client";
    import { useState } from "react";
    import { toast } from "@funstack/ui/toast";
    import { sleep } from "./fake-api.js";
    
    const initial = ["Groceries", "Dentist", "Call Ada"];
    
    // "Do later, unless undone": the item leaves the list at once (local state), and the toast is the
    // grace period. `onClose` is called when the toast leaves, with the reason: "activate" when Undo
    // was used, otherwise ("timeout", or "dismiss" through Close, Escape or toast.dismiss()) the
    // deletion is committed. It is a handler, not an action: not awaited, so the slow delete holds
    // no other transition, and a rejection would go to reportError. Hover or focus the toast to pause
    // its 6 second timer.
    export function ToastUndoWindow() {
      const [items, setItems] = useState(initial);
      const [log, setLog] = useState<readonly string[]>([]);
      // Called from onClose, a handler: a plain setState there is an urgent update, even after an await.
      const note = (line: string) => setLog((l) => [line, ...l].slice(0, 3));
    
      const remove = (name: string) => {
        setItems((list) => list.filter((item) => item !== name));
        toast({
          title: `Deleted “${name}”`,
          duration: 6000,
          action: {
            label: "Undo",
            action: () => setItems((list) => [...list, name]),
          },
          onClose: async ({ reason }) => {
            if (reason === "activate") {
              note(`Restored ${name}`);
              return;
            }
            await sleep(300); // the real delete request
            note(`Deleted ${name} for good (${reason})`);
          },
        });
      };
    
      return (
        <div className="demo-stack">
          <ul className="demo-toast-list">
            {items.map((name) => (
              <li key={name}>
                <span>{name}</span>
                <button type="button" className="demo-button" onClick={() => remove(name)}>
                  Delete
                </button>
              </li>
            ))}
            {items.length === 0 && (
              <li>
                <button type="button" className="demo-button" onClick={() => setItems(initial)}>
                  Reset list
                </button>
              </li>
            )}
          </ul>
          <ul className="demo-readout">
            {log.map((line, i) => (
              <li key={i}>{line}</li>
            ))}
          </ul>
        </div>
      );
    }

    onClose is a handler, not an action: it is not awaited, so a slow deleteForReal holds no other transition in the app, and it may be a Server Function. A rejection, or a throw, goes to reportError; it never reaches an Error Boundary (the toast has already left). To show the user a failure, catch it yourself:

    toast({
      title: "Message deleted",
      duration: 8000,
      action: { label: "Undo", action: () => restoreToList(id) },
      onClose: async ({ reason }) => {
        if (reason === "activate") return;
        try {
          await deleteForReal(id);
        } catch {
          restoreToList(id);
          toast({ title: "Could not delete the message", priority: "high" });
        }
      },
    });

    An Undo toast waits in the queue like any other. When limit toasts are already visible (three "Card moved" toasts, say), it is not rendered until one of them leaves, and the user cannot reach its Undo in the meantime. Its timer has not started, so the Undo window is not used up while it waits. To keep low-value toasts from hiding it:

    • give repeated success toasts one id, so a new one updates the visible toast in place instead of queueing;
    • give them a short duration, or close them with toast.dismiss(id) before you show the Undo toast;
    • render state.queued in the Viewport ("+2 more"), so the user knows that more is waiting;
    • raise limit.

    Timers

    A toast's timer starts once it is visible (within limit), its content has rendered and it is not pending, and resumes with the remaining time after a pause. Timers pause while the pointer is over the region, focus is inside it, the document is hidden or the window is blurred (data-paused), and per toast while it is pending. Elapsing closes the toast with reason: "timeout". Pausing helps sighted users; the persistent default for action toasts and the hotkey are what give screen-reader users time to reach an Undo.

    Props

    toast(options) and the manager

    PropTypeDefaultDescription
    toast(options)(options: ToastOptions) => string–Adds a toast and returns its id (or updates the toast with options.id). Also toast.add.
    toast.promise<T>(promise: PromiseLike<T>, options: ToastPromiseOptions<T>) => Promise<T | undefined>–{ pending, success?, error?, id? }; success / error are options or functions of the value / reason. See the table above.
    toast.update(id: string, options: Partial<ToastOptions>) => void–Changes a toast in place; undefined removes a field. Ignored for a closed toast; an unknown id warns in development.
    toast.dismiss(id?: string) => void–Closes one toast, or all, with reason: "dismiss". Idempotent.
    createToastManager() => ToastManager–An isolated queue with the same shape, for Toast.Viewport manager.

    On the server every method is a no-op with a development warning, and nothing is buffered (a module-level queue would be shared between requests). Return data from a Server Function and call toast() on the client.

    ToastOptions

    PropTypeDefaultDescription
    titleReactNode–Rendered by Toast.Title; part of the default announcement.
    descriptionReactNode–Rendered by Toast.Description; part of the default announcement.
    idstringgeneratedAn existing id updates that toast.
    typestring–Free-form ("success", "error"), rendered as data-type on the Root.
    priority"normal" | "high""normal""high": announced with ariaNotify priority "high", Root role alertdialog.
    durationnumber | nullViewport duration; null with an actionMilliseconds until the toast closes with reason: "timeout"; null never. A toast with an action is persistent unless you set it; if you do, keep the action reachable elsewhere too (WCAG 2.2.1).
    action{ label: ReactNode; action: Action<[details: ToastActionDetails & Rejectable]> }–What Toast.Action renders and runs. details.id is the toast's id, so an inline action can update or dismiss its own toast.
    onCloseUrgentHandler<ToastCloseDetails>–A handler, not an action: called once when the toast leaves, synchronously, outside any transition, and not awaited; details.reason is "activate", "dismiss" or "timeout". May return a promise (a Server Function); a rejection or a throw goes to reportError. Not called when the Viewport unmounts.
    announce(toast: ToastItem) => string | null–The text ariaNotify speaks for this toast; null for nothing. Wins over the Viewport's announce.
    dataunknown–Anything your Viewport children want to render.

    ToastItem, what state.toasts holds: the options plus id, pending (its promise is unsettled or its Action runs) and ending (closed, kept for its exit animation).

    Toast.Viewport

    PropTypeDefaultDescription
    managerToastManagertoastThe queue to render.
    limitnumber3Toasts rendered at once; the rest wait in order.
    durationnumber | null5000Default duration of a toast without an action.
    hotkeystring[] | null["F8"]event.code values and modifier names ("altKey", "ctrlKey", "metaKey", "shiftKey") that focus the newest toast, with no other modifier held (Ctrl+F8 is not F8). Also names the region ("Notifications (Alt+T)"). null installs no listener.
    announce(toast: ToastItem) => string | null–The announcement text for every toast (localisation). Default: the text of its Title and Description.
    aria-labelstring"Notifications (F8)"The region's name; yours is used verbatim.
    classNamestring | ((state: ToastViewportState) => string | undefined)–A class name, or a function of the part's state.
    styleCSSProperties | ((state: ToastViewportState) => CSSProperties | undefined)–Inline style, or a function of the part's state.
    childrenReactNode | ((state: ToastViewportState) => ReactNode)–Usually a function of the state that maps state.toasts to Toast.Roots.
    renderReactElement | ((props, state: ToastViewportState) => ReactNode)–Replace the default <section> (element form) or take over rendering (function form).
    State
    ToastViewportState is { toasts, queued, paused, empty }; toasts is chronological (oldest first) and includes the ones animating out; paused is true while a viewport-wide pause holds; empty is true while no toast is rendered (data-empty).
    Owned
    popover ("manual"), aria-label (your own wins verbatim), data-paused, data-empty, and the pointer and focus handlers.

    Toast.Root

    PropTypeDefaultDescription
    toastToastItem–Required. An item of state.toasts; key the Root (or its wrapper) on toast.id.
    fallbackReactNodenullShown inside the Root while its children suspend (a skeleton). The timer and the announcement wait for the reveal; the Root is not data-pending meanwhile. Parts inside it (a visually hidden Toast.Title) name the toast but gate nothing.
    classNamestring | ((state: ToastRootState) => string | undefined)–A class name, or a function of the part's state.
    styleCSSProperties | ((state: ToastRootState) => CSSProperties | undefined)–Inline style, or a function of the part's state.
    childrenReactNode | ((state: ToastRootState) => ReactNode)–Content, or a function of the part's state.
    renderReactElement | ((props, state: ToastRootState) => ReactNode)–Replace the default <div> (element form) or take over rendering (function form).
    State
    ToastRootState is { toast, pending, ending, type, priority }.
    Owned
    role (dialog, or alertdialog for priority: "high"), tabIndex, inert (while ending), onKeyDown, data-type, data-priority, data-pending, data-ending. aria-labelledby and aria-describedby name the Title and the Description only while each is mounted (a Description with no content renders nothing), merged with yours.

    Toast.Title (div) and Toast.Description (p) take the same function props against the Root's state (exported as ToastTitleState and ToastDescriptionState); their children default to toast.title / toast.description, and the Description renders nothing when it has neither.

    Toast.Action

    PropTypeDefaultDescription
    actionAction<[details: ToastActionDetails & Rejectable]>toast.action.actionRuns in this part's transition. The part renders nothing when neither it nor the toast has an action.
    closeOnActivatebooleantrueClose the toast (reason: "activate") when the action resolves.
    whilePending"run" | "ignore""ignore", or "run" with closeOnActivate={false}What a click does while this part's action is pending. "ignore": nothing (the click is cancelled, aria-disabled="true" meanwhile). "run": the action runs again; the Action and the Root stay data-pending and the timer paused until every run has settled; with closeOnActivate the toast then closes once, if the latest run resolved (a rejection keeps it, in both modes). Set it on the part: toast({ action }) has no such option. See A second click while pending.
    disabledbooleanfalseNever runs the action. Native disabled; owned, so a render element cannot re-enable it. With a link or component render, aria-disabled="true" instead and the click is cancelled (a link does not navigate). A click runs no onClick, a render element's included, and is cancelled; a render element's disabled disables the part too (unavailable parts).
    classNamestring | ((state: ToastActionState) => string | undefined)–A class name, or a function of the part's state.
    styleCSSProperties | ((state: ToastActionState) => CSSProperties | undefined)–Inline style, or a function of the part's state.
    childrenReactNode | ((state: ToastActionState) => ReactNode)–Default: toast.action.label.
    renderReactElement | ((props, state: ToastActionState) => ReactNode)–Replace the default <button> (element form) or take over rendering (function form).
    State
    ToastActionState is { pending, disabled, toast }; disabled is the prop, never set by pending.
    Owned
    type (on a <button> only), disabled, onClick, aria-disabled, data-pending, data-disabled.

    By default (whilePending="ignore" unless closeOnActivate={false}) a second click while the action is pending is ignored (and cancelled): one Undo, one Retry. The Action is then aria-disabled="true" while it shows data-pending; it is never natively disabled, so it keeps focus.

    Toast.Close

    PropTypeDefaultDescription
    disabledbooleanfalseNever closes. Native disabled; owned, so a render element cannot re-enable it. With a link or component render, aria-disabled="true" instead and the click is cancelled (a link does not navigate). A click runs no onClick, a render element's included, and is cancelled; a render element's disabled disables the part too (unavailable parts).
    classNamestring | ((state: ToastCloseState) => string | undefined)–A class name, or a function of the part's state.
    styleCSSProperties | ((state: ToastCloseState) => CSSProperties | undefined)–Inline style, or a function of the part's state.
    childrenReactNode | ((state: ToastCloseState) => ReactNode)–Content, or a function of the part's state.
    renderReactElement | ((props, state: ToastCloseState) => ReactNode)–Replace the default <button> (element form) or take over rendering (function form).
    State
    ToastCloseState is { disabled, toast }.
    Owned
    type (on a <button> only), disabled, aria-disabled (link or component render), onClick, data-disabled.

    Closes the toast with reason: "dismiss", like Escape. Give it a name (text or aria-label); development warns otherwise.

    Data attributes

    AttributeOnMeaning
    data-pendingRoot, ActionThe toast's promise is unsettled, or its Action's action runs (not set while its content merely suspends)
    aria-disabledAction, Close"true" on the Action while data-pending with whilePending="ignore" (the default unless closeOnActivate={false}): a second click is ignored. Also on either part when disabled with a link or component render
    data-disabledAction, CloseThe part's disabled prop (never set by pending)
    data-endingRootClosed, kept (and inert) until the animations the ending state started finish
    data-typeRootThe toast's type
    data-priorityRoot"normal" or "high": the toast's priority, resolved
    data-pausedViewportA viewport-wide timer pause holds; pause a progress bar with it
    data-emptyViewportNo toasts rendered

    Keyboard and ARIA

    KeyWhereBehaviour
    F8 (hotkey)anywhereFocuses the newest toast; nothing (and no preventDefault) without toasts.
    Tab / Shift+TabViewportThrough each toast and its buttons in DOM order; nothing is trapped.
    ArrowDown / ArrowUpa toastNext / previous toast, no wrap. Elements inside that use the arrow keys themselves keep them: text, number, date, range and radio inputs, textarea, select, contenteditable, and the textbox, combobox, spinbutton and slider roles.
    Escapea toastDismisses it. A preventDefault() on the Escape keeps it; stopPropagation() does not.
    Enter / SpaceAction, CloseNative button activation.
    • When the toast holding focus closes, focus moves to the next toast, else the previous one, else back to where it was before the region was entered (by F8 or Tab), else the body.
    • F8, not F6: F6 is the browsers' pane-cycling key. Change it with hotkey.
    • One Escape closes one layer. A Tooltip or HoverCard that is showing, inside the toast or anywhere else on the page, closes first; so does a Menu, Popover or dialog open inside the toast. The next Escape dismisses the toast. A non-modal Dialog around the region stays open until the Escape after that.
    • Announcements go through document.ariaNotify(), never a live region: after the toast's content has rendered, again when an update changes its text, with priority: "high" for high-priority toasts; several toasts in one tick become one announcement. Dismissals are silent. A queued toast is announced when it is added.

    Transition types

    Concept: Transitions & ViewTransition

    None. Every Toast commit is urgent (so a toast shows even while an async action holds every transition), no part takes a transition prop, and React starts view transitions for transition commits only. Animate with CSS (@starting-style, [data-ending]).

    Optimistic and pending

    Concept: Pending & optimistic state

    No optimistic state. data-pending is on the Root while the toast's promise is unsettled or its Action's action runs, and on that Action, which is a pure trigger.

    Suspense

    Concept: Suspense

    Toast content may suspend; each Root has its own boundary and a fallback prop.

    Toast content may suspend (title: <UserName id={id} />). Each Root wraps its children in its own Suspense boundary, so a suspending toast does not pull the Viewport into the nearest boundary above it (a toast mounts urgently, where that boundary would show its fallback). While the content suspends the Root shows its fallback prop (nothing by default), in the same frame as the toast() call; the timer does not run and nothing is announced. On the reveal the toast announces its Title and Description and its timer starts. An update whose new content suspends shows the fallback again and pauses the timer until the next reveal.

    <Toast.Root key={t.id} toast={t} fallback={<ToastSkeleton />}>
      <Toast.Title />
      <Toast.Description />
    </Toast.Root>

    Use fallback rather than your own <Suspense> inside the Root: the toast is still announced when your boundary reveals its Title and Description, but its timer starts at once, because the library cannot see your boundary's fallback.

    Browser-owned state

    Concept: Browser-owned state

    The region is a popover="manual" in the top layer, shown while it has toasts and never light-dismissed. Its stack is library-owned.

    Top layer and modal dialogs

    The region is popover="manual": shown while it has toasts, it neither closes an open menu or popover nor is closed by one, and it has no light dismiss. A toast added while a later menu or popover covers the region raises it to the top again. A top-layer element outside an open modal <dialog> is inert, so while a Dialog is open as a modal the region moves into it (and back when it closes): an Undo stays clickable. The move keeps the toasts' React state (an Undo in flight stays pending), but it is a DOM move: the toasts' enter animation plays again and focus inside a toast is lost. Dialogs the library did not open are not detected.

    Before hydration

    Concept: Server Components

    Toasts appear only after hydration.

    <Toast.Viewport> takes a function child, so render it from a Client Component file that a Server Component layout includes. On the server it renders the empty region. toast() is client code: a Server Function returns data and the client calls toast() with it (in the action that called it, or in an effect on useActionState's result).

    Styling

    Enter with @starting-style, exit on [data-ending]: the library keeps a closed toast mounted until the animations (transitions included) that [data-ending] started finish. Animations already running in the toast, such as a progress bar paused with data-paused, are not waited for. Toasts never use <ViewTransition> and no part has a transition prop: every Toast commit is urgent, and react-dom starts view transitions for transition commits only. Make the region's box click-through with pointer-events: none and give it back to the toasts; stack visually with flex-direction: column-reverse and :nth-last-child().

    While a modal Dialog, AlertDialog or Drawer is open, the region is a DOM child of that dialog (Top layer and modal dialogs). It is still in the top layer, above the dialog and placed against the viewport, so toasts at the bottom of the screen can cover a bottom drawer's buttons. Being inside the dialog, the toasts inherit its font and color, match its descendant selectors (.dialog p) and are part of its textContent. Set the properties the toasts rely on, on the region or the toasts themselves. To move them out of a bottom drawer's way:

    /* .toasts is your Viewport's className; Drawer.Popup has data-side. */
    html:has(dialog[data-side="bottom"][open]) .toasts {
      inset-block: 1rem auto; /* top of the screen while a bottom drawer is open */
    }

    Browser notes

    • ariaNotify is in Chrome 141, Firefox 150 and Safari 27; where it is missing nothing is announced and nothing throws.
    • No swipe to dismiss yet: Close, Escape and the timer cover WCAG 2.5.1.