Undo Pill
"3 files deleted · Undo" with a countdown ring that pauses while you reach for it.
PROGet Undo Pill and 168 other Pro components with pro lifetime — Get Pro
- Category
- Data & feedback
- Access
- ProPro · unlocked
- Source
- 167 lines · one file
- States
- 4 drawn
The decision inside it
Undo beats are-you-sure
A mistake costs one click and nobody confirms the hundred deletes they meant. The real change waits for onExpire.
When to use it
Use Undo Pill right after an action that is done but can still be taken back: archive, delete, move. It counts down and pauses while hovered or focused. For other messages use a toast.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Undo Pill for this.
Install it: npx shadcn@latest add @liro/undo-pill
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/undo-pill.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { UndoPill } from "@/components/ui/undo-pill";
export function ArchiveUndo({ open, restore, close }: { open: boolean; restore: () => void; close: () => void }) {
return <UndoPill open={open} message="3 contracts archived" onUndo={restore} onExpire={close} />;
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
open | boolean | Yes | Shown while true. Set it false after onUndo or onExpire. |
message | string | Yes | What happened, e.g. "3 files deleted". |
duration | number | No | Milliseconds before it expires. Default 5000. |
onUndo | () => void | Yes | Put it back. The pill closes. |
onExpire | () => void | No | The time ran out or the pill was closed: make the change for real. |
position | "bottom" | "top" | No | Where it sits. Default bottom. |
strategy | "fixed" | "absolute" | No | Over the page, or inside the nearest positioned parent. Default fixed. |
undoLabel | string | No | The button's words. Default "Undo". |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themeStates
All of them are drawn by the component. None is left for you to design.
- Counting down
- Paused
- Undone
- Expired
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances