useToast
App-wide notifications. Mount AppToast once (App.vue) with the toasts ref. Call success, error, warning or info from anywhere. At most five show at once, a toast can carry one action (Undo), and promise() turns a loading toast into the outcome.
Install: pnpm add-composable useToast
Interactive board
Trigger various notification types to experience the smooth animation and auto-dismissal logic.
API
success, error, warning, info((message, { title?, description?, icon?, position?, autopilot?, duration?, action? }) => string): Shows a toast and returns its id. duration 0 keeps it until dismissed. description is a second, longer line; icon replaces the type icon; position and autopilot are per-toast overrides for AppToast.action({ label: string; onClick: () => void }): Option. One button beside the message; it runs, then the toast closes.promise((promise, { loading, success, error }) => Promise<T>): A sticky loading toast (type loading) that becomes success or error; AppToast morphs the pill between them. success and error may be functions of the result. Resolves or rejects with the promise.update((id, patch) => void): Changes a toast in place. A new duration restarts its timer.remove, clear((id) => void, () => void): Closes one toast, or all of them.pause, resume((id) => void): Freezes the timer and progress bar; AppToast calls these on hover and focus.toasts(Ref<Toast[]>): The queue, for AppToast.configureToasts(({ max?, duration? }) => void): Separate export. App-wide limit and default duration; past the limit the oldest toast goes.