Toast
Glassmorphic toast notifications powered by Sonner with success, error, warning, info, loading, promise, and action support.
pnpm dlx @glinui/cli@latest add toastProfile
Changes to your display name and photo apply across the workspace.
Installation
pnpm dlx @glinui/cli@latest add toastPrefer the package?
Usage
Stacked variants
Fire several toasts in a row: they stack, collapse and can be dismissed with the close button.
Notification variants
Fire a few in a row to see them stack and collapse.
"use client"
import { Trash, Warning, X } from "@phosphor-icons/react"import { Button, Heading, Text, Toaster, toast} from "@glinui/ui"
export function ToastStackHero() { return ( <div className="mx-auto grid w-full max-w-md gap-4 rounded-2xl border border-[var(--line-soft)] bg-[var(--surface-1)] p-5 [box-shadow:var(--elev-1)]"> <Toaster position="bottom-right" closeButton visibleToasts={4} /> <div> <Heading level={3} size="sm">Notification variants</Heading> <Text size="sm" className="mt-1 text-[var(--color-muted)]">Fire a few in a row to see them stack and collapse.</Text> </div> <div className="flex flex-wrap gap-2"> <Button size="sm" onClick={() => toast.success("Deploy finished", { description: "lumen-web is live on production." })}>Success</Button> <Button size="sm" variant="outline" onClick={() => toast.warning("Storage almost full", { description: "You have used 92 percent of your plan." })}> <Warning aria-hidden="true" /> Warning </Button> <Button size="sm" variant="outline" onClick={() => toast.error("Payment failed", { description: "Your card ending 4242 was declined." })}> <X aria-hidden="true" /> Error </Button> <Button size="sm" variant="outline" onClick={() => toast("File deleted", { description: "launch-banner.png moved to trash.", action: { label: "Undo", onClick: () => toast.success("Restored") } })}> <Trash aria-hidden="true" /> With undo </Button> </div> </div> )}Action Button
import { Toaster, toast, Button } from "@glinui/ui"
export function Demo() { return ( <> <Toaster position="bottom-right" /> <Button onClick={() => toast("File deleted", { description: "The file has been moved to trash.", action: { label: "Undo", onClick: () => toast.success("Restored") } })}> With action </Button> </> )}Promise Toast
import { Toaster, toast, Button } from "@glinui/ui"
export function Demo() { const fetchData = () => new Promise((resolve) => setTimeout(resolve, 2000)) return ( <> <Toaster position="bottom-right" /> <Button onClick={() => toast.promise(fetchData(), { loading: "Generating report...", success: "Report is ready!", error: "Failed to generate report" })}> Promise toast </Button> </> )}Variants
Pick a look, then fire a toast. The Toaster owns the surface of every toast; success, error, warning and info add a leading status bar.
import { Button, Toaster, toast } from "@glinui/ui"
// The Toaster owns the look of every toast it renders.export function Demo() { return ( <> <Toaster position="bottom-right" variant="plain" /> <Button onClick={() => toast.success("Saved", { description: "Rendered with the plain look." })}> Show toast </Button> </> )}Glass (opt-in)
variant="glass" is opt-in. It blurs and tints what sits behind the panel (with a readable opacity floor), so it needs a colourful or photographic backdrop: switch the stage backdrop to see it.
import { Button, Toaster, toast } from "@glinui/ui"
export function Demo() { return ( <> <Toaster position="bottom-right" variant="glass" /> <Button onClick={() => toast("Settings saved", { description: "Frosted, with a readable floor." })}> Show glass toast </Button> </> )}Custom Duration
Set `duration` per-toast or globally on the `Toaster`. ```tsx // 10 second toast toast("Long-running task", { duration: 10000 }) // Persistent toast (no auto-close) toast("Requires action", { duration: Infinity }) ```
Dismiss
Dismiss a specific toast by ID or all toasts at once. ```tsx const id = toast("Processing...") // Later... toast.dismiss(id) // dismiss specific toast.dismiss() // dismiss all ```
Glass Variant
Use `variant="glass"` on the `Toaster` for frosted glass surfaces. ```tsx <Toaster variant="glass" /> ```
Matte Variant
```tsx <Toaster variant="matte" /> ```
Positions
Six positions: `top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center`, `bottom-right`. ```tsx <Toaster position="top-center" /> ```
Accessibility
- Built on Sonner with ARIA live region announcements.
- Auto-pause on hover for reading time.
- Swipe-to-dismiss with configurable directions.
- Keyboard accessible with hotkey support.
- Auto-pause on hover gives users time to read.
- Keep toast messages short (under 140 characters) for screen readers.
Keyboard Interactions
| Key | Action |
|---|---|
| Escape | Dismiss the focused toast. |
| Alt+T | Focus the toast region (configurable). |
ARIA Attributes
- `role="status"` on toast region
- `aria-live` for live announcements
- `aria-label` on close and action buttons
Reduced Motion
Slide and opacity transitions respect `prefers-reduced-motion`.
Slide and opacity transitions respect `prefers-reduced-motion`. When enabled, toasts fade in without translate animation.
Affected properties
transformopacityAPI Reference
Toaster
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "glinr" | "plain" | "solid" | "soft" | "outline" | "ghost" | "gradient" | "glass" | ambient style (glinr) | Look of every toast: a glinr card by default, with a leading status bar for success, error, warning and info. `plain` is the shadcn card, `glass` is opt-in and needs a backdrop. Legacy `default` follows the ambient style, `matte` maps to `solid`. |
position | "top-left" | "top-right" | "top-center" | "bottom-left" | "bottom-right" | "bottom-center" | bottom-right | Position of the toast stack. |
expand | boolean | false | Expand all toasts by default. |
duration | number | 4000 | Default auto-dismiss time in ms. |
visibleToasts | number | 3 | Max visible toasts at once. |
closeButton | boolean | false | Show close button on every toast. |
richColors | boolean | false | Use Sonner rich colors for semantic types. |
theme | "light" | "dark" | "system" | system | Color scheme. |
hotkey | string[] | ["altKey", "KeyT"] | Keyboard shortcut to focus toasts. |
dir | "ltr" | "rtl" | "auto" | auto | Text direction. |
toast()
| Prop | Type | Default | Description |
|---|---|---|---|
toast(message, opts?) | function | - | Show a default toast. |
toast.success(message, opts?) | function | - | Show a success toast with checkmark icon. |
toast.error(message, opts?) | function | - | Show an error toast with alert icon. |
toast.warning(message, opts?) | function | - | Show a warning toast with triangle icon. |
toast.info(message, opts?) | function | - | Show an info toast with info icon. |
toast.loading(message, opts?) | function | - | Show a loading toast with spinner. |
toast.promise(promise, opts) | function | - | Auto loading → success / error based on promise outcome. |
toast.custom(jsx) | function | - | Render custom JSX as a toast. |
toast.dismiss(id?) | function | - | Dismiss a specific toast or all toasts. |
Toast Options
| Prop | Type | Default | Description |
|---|---|---|---|
description | ReactNode | - | Secondary text below the title. |
duration | number | 4000 | Per-toast auto-dismiss time in ms. |
icon | ReactNode | - | Custom icon override. |
action | { label: ReactNode; onClick: () => void } | - | Action button config. |
cancel | { label: ReactNode; onClick: () => void } | - | Cancel button config. |
onDismiss | (toast) => void | - | Callback when toast is dismissed. |
onAutoClose | (toast) => void | - | Callback when toast auto-closes. |
dismissible | boolean | true | Allow swipe/click to dismiss. |
className | string | - | Per-toast class override. |
Source
Import directly from the package or browse the source on GitHub. Click any file to view it.
Generated API Snapshot
Beta
Generated API Snapshot
BetaAuto-extracted from TypeScript source in packages/ui/src/components/toast.tsx. This section is in beta and may lag behind hand-curated docs. Regenerate with pnpm --filter @glinui/docs api:generate.
Generated: 2026-10-08T01:41:21.546Z · Full index: /docs/api-metadata
Primary Props Type
ToastProps
ToastCloseProps
No explicit fields extracted for this props type.
ToastDescriptionProps
No explicit fields extracted for this props type.
ToastProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
size | "sm" | "md" | "lg" | No | "md" | Variant option from toastVariants. |
tone | "none" | "success" | "warning" | "danger" | "info" | No | "none" | Variant option from toastVariants. |
variant | PanelVariantProp | ToastStatus | No | - | Surface look, or a status (`success`, `warning`, `destructive`, `info`) which keeps the ambient look and adds a status bar. Omit for the ambient design style (glinr by default). `glass` is opt-in. |
ToastTitleProps
No explicit fields extracted for this props type.
ToastViewportProps
No explicit fields extracted for this props type.