Undo Pill
The action looks done straight away and is committed in onExpire when the ring runs out. The countdown pauses on hover, on focus and in a hidden tab; Undo is the first thing Tab reaches.
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 Layro's Undo Pill for this.
Install it: npx shadcn@latest add @layro/undo-pill
(the @layro registry is set up in components.json, with LAYRO_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 @layro 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.
| Prop | Type | Notes |
|---|---|---|
openrequired | boolean | Shown while true. Set it false after onUndo or onExpire. |
messagerequired | string | What happened, e.g. "3 files deleted". |
duration | number | Milliseconds before it expires. Default 5000. |
onUndorequired | () => void | Put it back. The pill closes. |
onExpire | () => void | The time ran out or the pill was closed: make the change for real. |
position | "bottom" | "top" | Where it sits. Default bottom. |
strategy | "fixed" | "absolute" | Over the page, or inside the nearest positioned parent. Default fixed. |
undoLabel | string | The button's words. Default "Undo". |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-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
Lifetime access
Every component, and everything we ship next.
- All 232 components, source included
- Every template, and everything released after you buy
- shadcn CLI or download — React 18/19, Tailwind v4
- One payment. No subscription.