Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Toast

A toast is two pieces: a store (createToaster) that owns the timers, queue and dismissal, and a Toaster component that renders the region. One store per app; call store.info(...), store.success(...) and friends to raise a toast.

The Toaster island is mounted below. Raising a toast needs a store shared with a button, which has to live in its own component so the store survives the island boundary.

import { Toaster, createToaster } from "@/components/ui/toast";
const toaster = createToaster({ placement: "bottom" });
// Raise a toast from anywhere
toaster.success({ title: "Settings tersimpan" });
// Mount the region once, near the app root
<Toaster toaster={toaster} />
Terminal window
npx @glaceon/cli add toast --framework react # or svelte, solid

The store exposes data, and the group renders one live region for all toasts. There are no per-toast data-* attributes: the region is the accessible surface.

Element Attribute Value Description
group role "region" The toast region.
group aria-live "polite" New toasts are announced without interrupting.
group aria-relevant "additions text" Only additions are announced.
group data-placement "bottom" | "top-start" | … Where the region is anchored.
group data-side / data-align e.g. "bottom" / "center" Derived from placement.

createToaster(options)

Option Type Default Description
placement "bottom" | "top" | "bottom-start" | … "bottom" Anchor for the region.
max number 24 Toasts beyond this are queued rather than shown.
duration number type-dependent Auto-dismiss delay in ms.
gap number 16 Space between stacked toasts.
overlap boolean false Stack toasts on top of each other.

Store methods

Method Description
create({ title, description, type }) Raises a toast and returns its id.
info / success / warning / error / loading Shorthand for the matching type.
update(id, data) Patches an existing toast.
dismiss(id?) Starts the exit; omit the id to dismiss all.
remove(id?) Removes immediately.
getVisibleToasts() The current toasts.
pause(id?) / resume(id?) Stops and restarts the auto-dismiss timer, used while the pointer is over the region.

<Toaster toaster={store} />

Prop Type Default Description
toaster store required The store created by createToaster.
class / className string undefined Extra classes for the region.

Every toast sits in a single aria-live="polite" region, so screen readers announce it when it appears without stealing focus. Each toast carries its own dismiss button with an accessible name, so a toast can be dismissed by keyboard. Hovering or focusing the region pauses the auto-dismiss timer, so a toast does not vanish while it is being read.