@bimetal/toast-headless
v0.40.0
Published
Canonical, framework-agnostic toast controller (createToastController) on @bimetal/headless-core. The family's first LIGHTWEIGHT / FEEDBACK component — controller-only (no store, no aggregate, no undo). Owns the presentation lifecycle: queue, per-toast li
Maintainers
Readme
@bimetal/toast-headless
The canonical, framework-agnostic toast controller — the BIMETAL component family's first lightweight / feedback member.
Controller-only: no store, no aggregate, no undo. The app pushes an already-decided message; the controller owns the whole presentation lifecycle so it behaves identically across React, Vue, Svelte, Angular and vanilla:
- a queue with a
maxcap (oldest dropped past it), - per-toast lifetime + auto-dismiss timers (
durationMs,0= sticky), - manual close, pause/resume (pointer-over the stack),
- semantic variants (
info | success | warning | error) and a position hint.
It has no domain dependency — in particular, no calendar and no undo/redo knowledge.
Reacting to a domain event (e.g. a calendar undo) is the application's job: observe the
event, decide the message, and call push(...).
import { createToastController } from '@bimetal/toast-headless';
const toasts = createToastController({ config: { position: 'bottom-end', durationMs: 4000 } });
// The app decides the message — the toast never inspects a domain.
const id = toasts.push({ message: 'Änderung rückgängig gemacht', variant: 'info' });
toasts.pause(); // pointer entered the stack
toasts.resume(); // pointer left
toasts.dismiss(id);Bind it with the thin per-framework packages (@bimetal/toast-react-components, …) or
the generic useToastController hook.
