Client component

Toast

Ephemeral notifications fired imperatively from anywhere: no context, no wiring.

Import#

import { Toaster, toast } from "astralis-ui";

Mount one <Toaster /> near your app root (inside AstralisProvider), then call toast(...) from any event handler, effect, or async flow. The store is module-level, so it works outside React trees too.

Options: actions, sticky toasts, dismiss#

toast() API#

CallReturnsDescription
toast(options)idFull-control form.
toast.info/success/warning/error(title, options?)idStatus shorthands.
toast.dismiss(id?)NoneClose one toast, or all when called with no id.

Options#

PropTypeDefaultDescription
titleReactNodeNoneThe headline. Required.
descriptionReactNodeNoneSupporting copy.
status"info" | "success" | "warning" | "error""info"Picks the icon and hue, and whether the announcement is polite or assertive.
colorSchemeall 15 schemesfrom statusHue override.
durationnumber | null5000Auto-dismiss delay in ms; null keeps the toast until it's dismissed.
closablebooleantrueShows the dismiss button and lets Escape dismiss the focused toast.
action{ label: string; onClick: () => void }NoneA button after the text.

<Toaster /> props#

PropTypeDefaultDescription
placement"top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end""bottom-end"The screen corner or edge the stack grows from.
maxnumber5How many toasts show at once, newest first. The rest wait their turn.

Keyboard#

Toasts never take focus when they appear, so they don't interrupt typing. They sit in a "Notifications" region you can Tab into.

KeyAction
TabMove to a toast's action and dismiss buttons
Enter / SpaceActivate the focused button
EscDismiss the focused toast and return focus to where it was

Esc only dismisses a closable toast, and it doesn't also close a Modal or Popover open behind it.

Accessibility#

  • Toasts are announced through two live regions the Toaster mounts empty: polite for info and success, assertive for warning and error. Regions that exist before their text arrives are announced reliably across screen readers, unlike one inserted already filled.
  • The toasts themselves sit in a role="region" labelled "Notifications".
  • Hovering a toast, or moving focus into it, pauses the auto-dismiss timer, which resumes with the remaining time, so slow readers aren't raced.