Skip to content

Toast ​

Imperative global toasts supporting success/error/warning/info/loading states, action buttons, promise chains, queue governance, and keyboard/screen-reader accessibility; auto-dismisses after 3 seconds by default.

Basic usage ​

Five types

SuccessErrorWarningInfoLoading

Custom duration ​

Custom duration

2s5sNo auto-close (0)Close manually

Action buttons ​

Action buttons (multiple + noDismiss + variants)

Single actionMultiple + noDismissNot closable

Position ​

Position (9 directions)

top-righttop-lefttop-centerleftcenterrightbottom-centerbottom-leftbottom-right

Promise chain ​

Promise chain

Simulate successSimulate failure

Lifecycle and onClose ​

Lifecycle and onClose callback

onClose (auto)onClose (manual)Trigger close

Update and dismiss by id ​

Update and dismiss by id

Start uploadUpdate progressCompleteClose

Notification storm governance ​

Max queue and content grouping

Click repeatedly (max=3 queue)Close #N (fill in)Same content (grouped count)Clear all

Beyond 3 visible toasts, extras queue and fill in after one closes; `priority` lets a high-priority toast preempt a visible slot.

Reading grace ​

Hover/focus pause + remaining-time progress

Pause timer + progressProgress ringTop progress

Window blur (switching tabs/windows) also pauses; disable individually with `pauseOnHover`/`pauseOnFocus`/`pauseOnWindowBlur`.

Keyboard and screen reader ​

Esc close and screen-reader politeness

Esc closepolite liveassertive live

Swipe to dismiss ​

Swipe to dismiss

Both directionsLeft only

Collapsed stacking ​

Collapsed stacking (+N fold / peek)

Trigger repeatedly (fold)

The newest toast stays fully visible while the rest peek behind with a +N badge; hover/focus expands them, clicking +N keeps them expanded.

Variants and animation ​

Variants (plain/translucent) and animation config

solidplaintranslucentSpringy slow animationRestore default animation

Animation duration/easing go through CSS variables `--oas-toast-enter-duration` / `--oas-toast-leave-duration` / `--oas-toast-ease`, no JS config needed.

Global default config ​

Global default config (toast.config)

Apply global defaultsRestore defaults

Mount point and named instances ​

Mount point and named toaster instances

Custom containerconsole instanceClear console instance

Declarative usage ​

Declarative usage (controlled open)

Toggle visibility (open)

API ​

Methods ​

MethodDescription
toast.info(options)Info toast, returns { close, update }
toast.success(options)Success toast, returns { close, update }
toast.warning(options)Warning toast, returns { close, update }
toast.error(options)Error toast, returns { close, update }
toast.loading(options)Loading toast (not closable), returns { close, update }
toast.promise(promise, opts)Promise chain: loading → success/error
toast.update(id, options)Update a toast in place by id; creates one if missing
toast.dismiss(id)Close a toast by id (visible or queued)
toast.config(options)Global default config (per-call wins)
toast.toaster(name)Named instance: isolated stacks/queues/config
destroyAllToast()Clear all instances

options ​

FieldDescriptionTypeDefault
titleTitle (string or Node)string | Node—
descriptionDescriptionstring—
action / actionsAction buttons (multiple + noDismiss + variant)ToastAction | ToastAction[]—
durationAuto-dismiss duration (ms); 0 keeps it opennumber3000
closableWhether it can be closed manually (loading is always unclosable)booleantrue
positionPosition (9 directions)ToastPositiontop-right
idUnique id for update / dismissstring—
onCloseClose callback (auto/manual/button/dismiss/destroyAll each fire once)() => void—
priorityPriority: with the max queue, higher preempts a visible slotnumber0
maxMax visible toasts in the position stack; extras queuenumberInfinity
politenessScreen-reader sensitivity: assertive / politestringby type
showProgressRemaining-time progress bar (shown when duration>0)booleanfalse
progressRingProgress ring close button (shown when duration>0)booleanfalse
groupingSame-content dedupe: merge in the same stack and bump the count badgebooleanfalse
swipeDirectionSwipe direction: both/right/left/up/downstringboth
stackedCollapsed stacking mode (+N fold / peek)booleanfalse
variantVariant: solid/plain/translucentstringsolid
containerMount point (element or function), overrides the default hostHTMLElement | () => HTMLElement—
pauseOnHover / pauseOnFocus / pauseOnWindowBlurPause timer toggles (all on by default)booleantrue

oas-toast ​

Attributes ​

AttributeDescriptionTypeDefault
closableWhether to show the close button (always disabled while loading)boolean—
countSame-content dedup count badge: with imperative grouping on, repeated dispatches of the same signature increment the count (×N next to the title, shown above 1) and reset the timerstring0
descriptionDescription textstring—
durationAuto-close duration in ms; pass 0 to keep it openstring3000
idInstance identity: imperative show/update/dismiss hit the existing instance by id to update/close in place instead of creating a new one; also used as the DOM id——
openControlled switch (declarative usage): open="false" hides the whole card and pauses the auto-close timer; absent/other values mean openstringtrue
pause-on-focusPause the auto-close timer while focus is inside (default on; "false" disables)——
pause-on-hoverPause the auto-close timer while hovered (default on; "false" disables)——
pause-on-window-blurPause the auto-close timer when the window loses focus or the page is hidden (default on; "false" disables)——
politenessScreen-reader politeness: polite (role=status) / assertive (role=alert, interrupts immediately); an explicit value wins, otherwise derived from type (error is assertive, others polite)string—
progress-positionProgress bar position: bottom (default) / top, together with show-progressstringbottom
progress-ringProgress-ring close button: an SVG ring around the ✕ tracks the remaining time (completes as duration elapses, when > 0)boolean—
show-progressShow the remaining-time progress bar for auto-close (duration follows duration, frozen while paused)boolean—
swipe-directionSwipe-to-dismiss direction: both (default) / right / left / up / down; the orthogonal axis follows with 0.2 dampingstringboth
titleTitle text (rendered into the visible title region; absorbed from the host on read so no native hover tooltip remains; pass an empty string to clear); use the "title" slot for rich contentstring—
typeToast type: info/success/warning/error/loadingstringinfo
variantVisual variant: default card / plain (no border/background, text straight out) / translucent (translucent frosted glass)——

Events ​

EventDescription
oas-closeEmitted on close, detail: { trigger } (trigger: auto/manual/action/close-button/esc/swipe/preempt/external); the node is removed after the leave animation
oas-destroyEmitted after the node is removed from the DOM (also as a fallback for external removal), detail: { trigger }; used to settle the promise chain
oas-openEmitted when shown, detail: { trigger }

Slots ​

NameDescription
titleRich title content slot; overrides the title attribute text when present

CSS Variables ​

CSS VariableDescriptionDefault
--oas-glass-blur—none
--oas-glass-refractionLiquid-glass edge refraction filter (active under data-glass, default none); for local opt-out override with an empty value (--oas-glass-refraction: ;)—not none (mixing none with button-state brightness() invalidates the whole filter declaration)none
--oas-glass-ring—transparent
--oas-toast-ease—ease
--oas-toast-enter-duration—0.2s
--oas-toast-leave-duration—0.2s
  • error defaults to role="alert" + aria-live="assertive"; others use role="status" + aria-live="polite"; override with politeness.
  • Multiple toasts share one stack container and stack by position; duration timers are cleaned up on close/unmount with no leaks.
  • Animation duration/easing are configured via CSS variables --oas-toast-enter-duration / --oas-toast-leave-duration / --oas-toast-ease.

Released under the MIT OR Apache-2.0 License.