Toast

Toasts acknowledge short-lived product events without interrupting the current workflow.

Overview and decision boundary

Use Toast to acknowledge short-lived product events without blocking the workflow.

Do not use Toast for destructive confirmations or blocking errors.

Preview

Static toast presentationStandalone feedback without managed positioning.
import { Button, ToastProvider, ToastViewport, useToastManager } from '@nerio-ui/ui/client';function Example() {  const toasts = useToastManager();  return (    <Button onClick={() => toasts.add({      id: "save-result",      title: "Saved",      description: "The collection is available to your team.",      timeout: 5000, // Use 0 only for an intentionally persistent toast.      priority: "low",      data: { tone: "success" },    })}>      Show toast    </Button>  );}<ToastProvider limit={3}>  <Example />  <ToastViewport label="Notifications" /></ToastProvider>

Installation and imports

Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.

pnpm dlx nerio add toastimport { Button, ToastProvider, ToastViewport, useToastManager } from '@nerio-ui/ui/client';

Usage

import { Button, ToastProvider, ToastViewport, useToastManager } from '@nerio-ui/ui/client';function Example() {  const toasts = useToastManager();  return (    <Button onClick={() => toasts.add({      id: "save-result",      title: "Saved",      description: "The collection is available to your team.",      timeout: 5000, // Use 0 only for an intentionally persistent toast.      priority: "low",      data: { tone: "success" },    })}>      Show toast    </Button>  );}<ToastProvider limit={3}>  <Example />  <ToastViewport label="Notifications" /></ToastProvider>

Variants

VariantPurpose
neutralLow-emphasis status or message.
infoInformational state that should stay calm.
successPositive completion or validation state.
warningWarning state that needs attention without blocking the whole flow.
dangerError, destructive, or blocking state.

Anatomy

SlotPurpose
viewportPortal layer where toasts are announced and positioned.
rootRoot slot exposed through data-slot="root".
contentContent slot exposed through data-slot="content".
status-indicatorStatus Indicator slot exposed through data-slot="status-indicator".
titleTitle slot exposed through data-slot="title".
descriptionDescription slot exposed through data-slot="description".
actionAction slot exposed through data-slot="action".
closeClose slot exposed through data-slot="close".

States

StatePurpose
TimedAuto-dismisses after the provider or toast timeout.
PersistentUses timeout 0 and always keeps a dismiss path.
PausedPreserves remaining time during pointer, keyboard focus, or window blur.
SwipingDismisses past the threshold and returns to position when cancelled.
Expanded stackExpands upward from a bottom-centered stack whose collapsed cards scale and step upward behind the frontmost toast.
LimitedKeeps overflow mounted but inert and visually hidden.

Motion

  • State changes should use shared motion tokens and preserve reduced-motion behavior.

Accessibility

  • Uses the Base UI Toast primitive and manager.
  • Use low priority for routine polite confirmations and high priority only for urgent updates.
  • Base UI announces managed title and description once; decorative status icons and action copy are excluded from the announcement.
  • Static Toast remains presentation-only and separate from managed status and stack behavior; managed actions and icon-only dismissal use Button.
  • The managed viewport is bottom-centered; collapsed toasts scale and step upward behind the frontmost card, then expand upward without changing reading order.
  • Managed toasts never steal focus. F6 enters the viewport, where actions and dismissal remain keyboard reachable.
  • Timers pause on pointer hover, keyboard focus, and window blur, then resume from the remaining duration. Set timeout to 0 only for an intentionally persistent toast.
  • Inherited document direction is resolved for the first interactive render and remains synchronized with root dir changes; explicit direction wins immediately.
  • Swipe supports pointer and touch input, logical RTL direction, four physical dismissal directions, cancellation, and reduced motion without replacing the dismiss control.
  • Use one provider per managed stack. Pass a manager from createToastManager only when an independent second provider is intentional.
  • Keep messages concise and avoid replacing persistent error UI with a toast.

API

PropPurpose
ToastProviderWraps one managed stack and configures limit, default timeout, and an optional independent manager.
ToastViewportSafe-area portal target with localized landmark/dismiss labels and RTL-aware swipe direction.
useToastManagerAdds, updates, replaces, and removes messages; duplicate IDs update in place and refresh their timer.
createToastManagerCreates an isolated manager when an application intentionally needs another provider.
timeoutMilliseconds before dismissal; 0 creates a persistent toast.
prioritylow is polite; high is reserved for urgent announcements.
dismissTextLocalizes the managed dismiss Button tooltip.
dismissLabelLocalizes the managed dismiss Button accessible name.
directionOverrides inherited document direction immediately with ltr or rtl.
swipeDirectionAccepts physical directions or logical inline-start and inline-end directions resolved from the viewport direction.

Implementation contract

ContractValue
Registry itemtoast installs 6 source files into the configured components directory.
Base UItoast
Registry dependenciesbutton
Package dependencies@base-ui/react, @nerio-ui/adapters, clsx, react, tailwind-merge, tailwindcss

Styling contract

ContractValue
AuthoringComplete, statically detectable Tailwind CSS v4 recipes own component visuals.
ValuesSemantic and component --n-* variables remain the canonical customization layer.
OverridesCustomizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically.
Residual CSSOnly shared keyframes and scoped no-Preflight compatibility rules remain; there is no parallel visual selector layer.

Design notes

  • Toast is an inverted dark glass surface in every mode so transient feedback is clearly separated from flat page content.
  • Semantic color is limited to the status icon; copy and controls use the toast foreground hierarchy.

Do / do not

Do

Confirm short-lived background events like saved, copied, or sent.

Use one provider and viewport per managed stack; create a separate manager only for an intentionally isolated stack.

Do not

Do not use Toast for destructive confirmations or blocking errors.

Do not turn Toast into a notification inbox, activity feed, job manager, or persistent history.

Tokens

These are the primary customization points. Override semantic or component tokens instead of changing component source.

TokenPurpose
--n-toast-widthPublic customization point for this component contract.
--n-toast-viewport-insetPublic customization point for this component contract.
--n-toast-stack-gapPublic customization point for this component contract.
--n-toast-stack-offsetPublic customization point for this component contract.
--n-toast-stack-scale-stepPublic customization point for this component contract.
--n-toast-enter-offsetPublic customization point for this component contract.
--n-toast-swipe-dismiss-distancePublic customization point for this component contract.
--n-overlay-z-indexPublic customization point for this component contract.
--n-toast-backgroundPublic customization point for this component contract.
--n-toast-borderPublic customization point for this component contract.
--n-toast-shadowPublic customization point for this component contract.
--n-toast-foregroundPublic customization point for this component contract.
--n-toast-foreground-mutedPublic customization point for this component contract.
--n-toast-control-backgroundPublic customization point for this component contract.
--n-toast-control-background-hoverPublic customization point for this component contract.
--n-toast-control-background-activePublic customization point for this component contract.
--n-toast-status-colorPublic customization point for this component contract.
--n-toast-status-infoPublic customization point for this component contract.
--n-toast-status-successPublic customization point for this component contract.
--n-toast-status-warningPublic customization point for this component contract.
--n-toast-status-dangerPublic customization point for this component contract.
--n-motion-reveal-durationPublic customization point for this component contract.
--n-motion-reveal-easingPublic customization point for this component contract.
--n-motion-focus-durationPublic customization point for this component contract.
--n-motion-focus-easingPublic customization point for this component contract.
--n-focus-ringPublic customization point for this component contract.