Undo Toast

Undo Toast is a copy-paste React component that stops deleted item gone with no undo before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/undo-toast
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 3 extra npm packages
  • A11y guidance in docs

StopsDeleted item gone with no undo

Was this component page useful?

How do I install Undo Toast?

pnpm dlx shadcn@latest add @bollard/undo-toast

The files land in your project. They're yours to edit.

How do I use Undo Toast in React?

undo-toast-usage.tsx
import { UndoToaster, undoable } from "@/components/ui/undo-toast"

<UndoToaster className="static inset-auto mx-0 max-w-none px-0" />

What input mistakes does Undo Toast catch?

  • Regretted actions, undone before onCommit runs
  • Countdown paused while hovered, focused or the tab is hidden
  • Leaving the page, which flushes pending commits
  • Failed commits, rolled back with a notice

What props does Undo Toast accept?

UndoToaster props
PropTypeDefault
hotkey

Bind Ctrl+Z / ⌘+Z to undo the newest pending action.

booleantrue
undoLabel

Label of each toast's undo button.

string"Undo"
failedText

Shown when a commit fails and is rolled back.

React.ReactNode"That didn't go through, so it was put back."
dismissLabel

Accessible label of the button that closes a failure notice.

string"Dismiss"

* required. Also accepts the native props of <section> (className, aria-*, data-*…), passed through to it.

How is Undo Toast accessible?

  • Toast region has an aria-label and polite live updates; failures use role=alert
  • Undo button has an aria-label with the message and aria-keyshortcuts
  • Ctrl/⌘+Z triggers undo when hotkey is on
  • Countdown ring respects reduced motion

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Commits on pagehide can't be awaited; use fetch keepalive or sendBeacon
  • If the tab crashes, a pending commit may never run
  • Other users may see the optimistic state only after commit

What expensive mistakes does Undo Toast stop?

Deleted item gone with no undo

Also known as

undo · snackbar · toast · sonner · optimistic update · ctrl+z · gmail undo · archive

What dependencies does Undo Toast require?

Undo Toast facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameUndo Toast
Registry identifier@bollard/undo-toast
Install commandnpx shadcn@latest add @bollard/undo-toast
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencies@number-flow/react, lucide-react, motion
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Undo Toast

How does Undo Toast protect AI agent operations?

Undo Toast stops deleted item gone with no undo. Runs actions optimistically and commits only after an undo window, so a mistake can be taken back without an "Are you sure?". It validates autonomous actions against Regretted actions, undone before onCommit runs, Countdown paused while hovered, focused or the tab is hidden, Leaving the page, which flushes pending commits, Failed commits, rolled back with a notice. Limitation: verify undo-toast policies at server boundary.

How do I install undo-toast with shadcn?

Run `npx shadcn@latest add @bollard/undo-toast`. Sources added: registry/default/undo-toast/undo-toast.tsx. Package requirements: @number-flow/react, lucide-react, motion.

What props customize Undo Toast?

Undo Toast accepts `hotkey`, `undoLabel`, `failedText`, `dismissLabel`. Configures undo, snackbar, toast behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of undo-toast?

Commits on pagehide can't be awaited; use fetch keepalive or sendBeacon. If the tab crashes, a pending commit may never run. Other users may see the optimistic state only after commit Server requirement: backend verification for undo-toast.

How does Undo Toast meet accessibility guidelines?

Toast region has an aria-label and polite live updates; failures use role=alert. Undo button has an aria-label with the message and aria-keyshortcuts. Ctrl/⌘+Z triggers undo when hotkey is on. Countdown ring respects reduced motion. Minimizes errors: deleted email no undo, accidentally archived item.

Which components pair with Undo Toast?