Glin UI
Primitive / Moleculebeta

Toast

Glassmorphic toast notifications powered by Sonner with success, error, warning, info, loading, promise, and action support.

Edit on GitHub

Profile

Changes to your display name and photo apply across the workspace.

AK
Ava Kim0 saves this session

Installation

Install from
pnpm dlx @glinui/cli@latest add toast

Prefer 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

KeyAction
EscapeDismiss the focused toast.
Alt+TFocus 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

transformopacity

API Reference

Toaster

PropTypeDefaultDescription
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-rightPosition of the toast stack.
expandbooleanfalseExpand all toasts by default.
durationnumber4000Default auto-dismiss time in ms.
visibleToastsnumber3Max visible toasts at once.
closeButtonbooleanfalseShow close button on every toast.
richColorsbooleanfalseUse Sonner rich colors for semantic types.
theme"light" | "dark" | "system"systemColor scheme.
hotkeystring[]["altKey", "KeyT"]Keyboard shortcut to focus toasts.
dir"ltr" | "rtl" | "auto"autoText direction.

toast()

PropTypeDefaultDescription
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

PropTypeDefaultDescription
descriptionReactNode-Secondary text below the title.
durationnumber4000Per-toast auto-dismiss time in ms.
iconReactNode-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.
dismissiblebooleantrueAllow swipe/click to dismiss.
classNamestring-Per-toast class override.

Source

Import directly from the package or browse the source on GitHub. Click any file to view it.

Import

import { Toast } from "@glinui/ui"

Source Files

Dependencies

@glinui/uisonner

Generated API Snapshot

Beta

Auto-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

PropTypeRequiredDefaultDescription
size"sm" | "md" | "lg"No"md"Variant option from toastVariants.
tone"none" | "success" | "warning" | "danger" | "info"No"none"Variant option from toastVariants.
variantPanelVariantProp | ToastStatusNo-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.