Primitive / Moleculebeta

Toast

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

@glinui/uiComponent: toast

Installation

Install from the package for shared ownership or from the registry for copy-paste control.

Package Manager

pnpm add @glinui/ui @glinui/tokens

Registry

pnpm dlx @glinui/cli@latest add toast

Usage

Basic

TSX
1import { Toaster, toast, Button } from "@glinui/ui"
2
3export 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 toast
11 </Button>
12 </>
13 )
14}

Toast Types

TSX
1import { Toaster, toast, Button } from "@glinui/ui"
2
3export 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

TSX
1import { Toaster, toast, Button } from "@glinui/ui"
2
3export 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 action
12 </Button>
13 </>
14 )
15}

Promise Toast

TSX
1import { Toaster, toast, Button } from "@glinui/ui"
2
3export 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 toast
14 </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

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`.

Affected properties

transformopacity

API Reference

Toaster

PropTypeDefaultDescription
variant"default" | "glass" | "matte"defaultSurface treatment for all toasts.
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-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

PropTypeRequiredDefaultDescription
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.