✦ Asteria UI
Components

Toast

Non-modal notification for brief action feedback, with info/success/warning/error variants and an imperative useToast() hook.

Installation

npx asteria-ui add toast

Usage

Render <Toast> directly for a static/controlled toast, or wrap your app in <ToastProvider> once and call useToast().toast(...) from anywhere to show one imperatively:

import { ToastProvider, useToast } from "@/components/ui/toast";

function Save() {
  const { toast } = useToast();
  return (
    <button
      onClick={() =>
        toast({ title: "Saved", description: "Your changes were saved." })
      }
    >
      Save
    </button>
  );
}

export function App() {
  return (
    <ToastProvider>
      <Save />
    </ToastProvider>
  );
}

Examples

Variants

Imperative usage

API reference

Toast

PropTypeDefaultDescription
titleReactNodeThe toast's primary message.
descriptionReactNodeOptional supporting text below the title.
variant"info" | "success" | "warning" | "error""info"Accent color and aria-live urgency (assertive for warning/error).
onDismiss() => voidCalled when the close button is activated. Omit to hide the close button.

useToast().toast(options) — additional options

PropTypeDefaultDescription
durationnumber6000Milliseconds before auto-dismiss. Set to 0 to disable auto-dismiss.
  • Alert — for persistent inline messages
  • Dialog — for messages needing confirmation
  • Modal — for blocking interactions

Accessibility

Accessibility

  • Role. role="alert", so screen readers announce the content immediately on mount.

  • Urgency. aria-live is "assertive" for warning/error variants and "polite" for info/success.

  • Dismiss. The close button has aria-label="Dismiss" and its own glow-focus ring.

  • Auto-dismiss. Configurable via duration (default 6s) — set to 0 to require manual dismissal.