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.
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-buttonOr 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 motionUsage
import UndoButton from "@/components/kokonutui/undo-button";
export default function Example() {
return <UndoButton />;
}Props
labelstringDefault "Archive"What the button does, e.g. "Archive".
doneLabelstringDefault "Archived"The same action in the past tense, e.g. "Archived".
iconLucideIconDefault ArchivedurationnumberDefault 5000How long the action can be undone, in ms.
resetAfternumber | nullDefault 2400After the action commits, go back to the start after this many ms. Pass null to stay on the done state.
onAction() => voidCalled when the button is pressed and the undo window opens.
onCommit() => voidCalled when the window closes without an undo: do the real work here.
onUndo() => voidclassNamestringExtra classes for the root element.
Dependencies
| Needs | Version | Comes from |
|---|---|---|
lucide-react | ^0.556.0 | npm, installed by the CLI |
motion | ^12.23.25 | npm, installed by the CLI |
cn from lib/utils.ts | shadcn init | |
| React | 19 | Your app |
| Tailwind CSS | 4 | Your app |
No provider, font or global CSS to set up: the file works as soon as it lands.

