Toast
Glassmorphic toast notifications powered by Sonner with success, error, warning, info, loading, promise, and action support.
Installation
Install from the package for shared ownership or from the registry for copy-paste control.
Package Manager
pnpm add @glinui/ui @glinui/tokensRegistry
pnpm dlx @glinui/cli@latest add toastUsage
Basic
1import { Toaster, toast, Button } from "@glinui/ui"23export function Demo() {4 return (5 <>6 <Toaster position="bottom-right" />7 <Button onClick={() => toast("Settings saved", {8 description: "Your workspace has been updated."9 })}>10 Show toast11 </Button>12 </>13 )14}
Toast Types
1import { Toaster, toast, Button } from "@glinui/ui"23export function Demo() {4 return (5 <>6 <Toaster position="bottom-right" />7 <div className="flex flex-wrap gap-2">8 <Button size="sm" onClick={() => toast.success("Saved")}>Success</Button>9 <Button size="sm" onClick={() => toast.error("Failed")}>Error</Button>10 <Button size="sm" onClick={() => toast.warning("Careful")}>Warning</Button>11 <Button size="sm" onClick={() => toast.info("Info")}>Info</Button>12 <Button size="sm" onClick={() => toast.loading("Uploading...")}>Loading</Button>13 </div>14 </>15 )16}
Action Button
1import { Toaster, toast, Button } from "@glinui/ui"23export function Demo() {4 return (5 <>6 <Toaster position="bottom-right" />7 <Button onClick={() => toast("File deleted", {8 description: "The file has been moved to trash.",9 action: { label: "Undo", onClick: () => toast.success("Restored") }10 })}>11 With action12 </Button>13 </>14 )15}
Promise Toast
1import { Toaster, toast, Button } from "@glinui/ui"23export function Demo() {4 const fetchData = () => new Promise((resolve) => setTimeout(resolve, 2000))5 return (6 <>7 <Toaster position="bottom-right" />8 <Button onClick={() => toast.promise(fetchData(), {9 loading: "Generating report...",10 success: "Report is ready!",11 error: "Failed to generate report"12 })}>13 Promise toast14 </Button>15 </>16 )17}
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.
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`.
Affected properties
transformopacityAPI Reference
Toaster
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "glass" | "matte" | default | Surface treatment for all toasts. |
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-02-19T17:59:28.468Z · 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. |
variant | "default" | "glass" | "frosted" | "matte" | No | "glass" | Variant option from toastVariants. |
ToastTitleProps
No explicit fields extracted for this props type.
ToastViewportProps
No explicit fields extracted for this props type.