03 · Undo
Sheet 03 · Components

Undo

Act right away and give people a few seconds to take it back.

Fig. 01

Await log waiting for you to try it

Installation
npx shadcn add @sureui/confirm-button
npx shadcn add @sureui/undo-toast
Usage
<ConfirmButton undo onConfirm={moveToTrash}>  Move to trash</ConfirmButton>if (await undoToast("Moved 3 files to trash")) {  await deleteFiles(ids)}
How it behaves
  • Nothing runs until the window ends: 5 seconds by default, or the number you pass, at least 4 seconds.
  • Undo calls onCancel, and onConfirm never runs.
  • If someone leaves the button and comes back to it, by pointer or keyboard, the window pauses until they leave again. Turn this off with pauseUndoOnHover={false} or pauseUndoOnFocus={false}.
  • Unmounting the control during the window drops the action without calling either handler. Closing the tab does the same.
  • undoToast pauses while the toast is hovered or has keyboard focus, and while the tab is hidden. Turn this off with pauseOnHover: false or pauseOnFocus: false.
  • Keep a trash or history view too, so people can still restore things after the window closes.
Props

ConfirmButton

undo
boolean | number
Default: 5000 when true, min 4000
undoLabel
ReactNode
Default: "Undo"
announcements.undo
string
Default: "Done. Undo is available."
pauseUndoOnHover
boolean
Default: true
pauseUndoOnFocus
boolean
Default: true
onConfirm
() => void | Promise<unknown>
Default: required
onCancel
() => void
Default: —
data-state
"idle" | "armed" | "holding" | "undo" | "pending"
Default: "idle"

undoToast(message, options)

message
ReactNode
Default: required
description
ReactNode
Default: —
duration
number
Default: 5000, min 4000
undoLabel
string
Default: "Undo"
pauseOnHover
boolean
Default: true
pauseOnFocus
boolean
Default: true
When to use it
Use it when
  • Moving files to trash, archiving mail, hiding a post.
  • People do it many times a day and expect it to be instant.
  • A mistake is noticed right after it happens.
Reach for something else when
© 2026 SureUI · MIT licensed · Built on shadcn/ui