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.
Interactive Preview
Section titled “Interactive Preview”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.
See the note in the React tab.
See the note in the React tab.
import { Toaster, createToaster } from "@/components/ui/toast";
const toaster = createToaster({ placement: "bottom" });
// Raise a toast from anywheretoaster.success({ title: "Settings tersimpan" });
// Mount the region once, near the app root<Toaster toaster={toaster} /><script lang="ts"> import Toaster from "@/components/ui/toast.svelte"; import { createToaster } from "@glaceon/svelte";
const toaster = createToaster({ placement: "bottom" }); toaster.success({ title: "Settings tersimpan" });</script>
<Toaster {toaster} />import { Toaster, createToaster } from "@/components/ui/toast";
const toaster = createToaster({ placement: "bottom" });
toaster.success({ title: "Settings tersimpan" });
<Toaster toaster={toaster} />Installation
Section titled “Installation”npx @glaceon/cli add toast --framework react # or svelte, solidbun add @zag-js/react @zag-js/toastCopy your framework’s implementation into your project. (Note: Code blocks omitted for brevity in preview, please refer to the source repository for full component code).
Data Attributes
Section titled “Data Attributes”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. |
API Reference
Section titled “API Reference”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. |
Accessibility
Section titled “Accessibility”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.