Skip to Content
Kokonut UI

BT-13Buttons

Undo Button

An action button that gives you a few seconds to take it back, with the time left drawn around its own edge.

Install with
lucide-react, motion

PROPay Button and more like it are in Kokonut UI Pro

Installation

Undo Button is a free, open-source React component in the Kokonut UI Buttons collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/undo-button.tsx, so the code is yours to change.

npx shadcn@latest add @kokonutui/undo-button

Or add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/undo-button.tsx.

npm install lucide-react motion

Usage

import UndoButton from "@/components/kokonutui/undo-button";

export default function Example() {
  return <UndoButton />;
}

Props

label
stringDefault "Archive"

What the button does, e.g. "Archive".

doneLabel
stringDefault "Archived"

The same action in the past tense, e.g. "Archived".

icon
LucideIconDefault Archive
duration
numberDefault 5000

How long the action can be undone, in ms.

resetAfter
number | nullDefault 2400

After the action commits, go back to the start after this many ms. Pass null to stay on the done state.

onAction
() => void

Called when the button is pressed and the undo window opens.

onCommit
() => void

Called when the window closes without an undo: do the real work here.

onUndo
() => void
className
string

Extra classes for the root element.

Dependencies

NeedsVersionComes from
lucide-react^0.556.0npm, installed by the CLI
motion^12.23.25npm, installed by the CLI
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

No provider, font or global CSS to set up: the file works as soon as it lands.