useSnackbarGroup

Snackbar
stable

Module-level singleton store for a named snackbar stack. Push notifications via notify(), dismiss them by id or all at once. Each call sharing the same id option reads and writes the same reactive items list — the composable and the matching <OrigamSnackbarGroup id="…"> component share live state with no event bus required.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

The store is a module-level Map keyed by id. It persists across component unmounts — dismissAll() or setting a low max are the recommended cleanup strategies. For testing, import resetSnackbarGroupForTesting() to wipe counters and timers between specs.

Consumed interfaces

IUseSnackbarGroupOptions
ISnackbarGroupItem
ISnackbarGroupItemOptions

API

Parameters

Input parameters accepted by this composable.

options
IUseSnackbarGroupOptions
{}
Optional configuration. id (string) namespaces the stack so multiple independent stacks can coexist on the same page (default: SNACKBAR_GROUP_DEFAULT_ID). max (number) caps the stack size with FIFO eviction. defaultDuration (ms) is the fallback auto-dismiss delay for items that omit their own (default: 5000 ms).

API

Return values

Properties and methods exposed by the composable return object.

items
Reactive read-only snapshot of the current stack. Mutate only through notify / dismiss / dismissAll — direct writes are blocked at the TypeScript level.
notify
Push a new item onto the stack. Accepts ISnackbarGroupItemOptions (message, variant, icon, duration, onDismiss callback…). Returns the generated item id so the caller can dismiss it early.
dismiss
Remove the item with the given id from the stack, cancel its auto-dismiss timer, and invoke its onDismiss callback if any.
dismissAll
Dismiss every item in the stack in one call. Iterates a snapshot of the ids so mid-loop mutations are safe.

Usage

Examples

Ready-to-paste usage snippets.

Push a success notification from any component

vue

Named stack with bounded capacity

vue