Undo snackbar
A “Done · Undo” bar that leaves on its own: its thin timer drains, hover or focus pauses it, and several stack — separate from the toaster, for actions that can be taken back.
Real scenarios
The component as it is used in a product — not a specimen grid.
Archive now, regret later
Archiving is instant — no confirm dialog. Each one stacks a snackbar whose thin timer drains over six seconds; hover or Tab into the stack and every timer stops. Undo brings the thread back where it was.
- Inbox zero. Undo any of them below.
Undo through the server
Here Undo calls a Livewire method with params — in your app, $this->dispatch('nx-undo', message: …, undo: 'restore', params: [$id]). The server answers with a toast.
Why not the toaster?
Toasts report; snackbars hold a decision open. The stack sits bottom-centre, keeps at most three on screen, and the drain bar is never the only cue — the message and the Undo button say it too.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| nx-undo (event) | array | — | From PHP: $this->dispatch('nx-undo', message: …, undo: 'restore', params: [$id]) — or $dispatch in Alpine. |
| duration | int | 6000 | The default lifetime; each message may carry its own duration. |
| undoLabel | string | 'Undo' | The Undo button’s label. |
| position | string | 'bottom-center' | bottom-center · bottom-start · bottom-end · inline. |
Snippet
<x-nx::undo-snackbar undo-label="بازگردانی" />
{{-- in the component --}}
$this->dispatch('nx-undo', message: 'فاکتور بایگانی شد', undo: 'restore', params: [$invoice->id]);