Undo Pill
Overview
An inline undo pill with a draining countdown ring that pauses on hover.
This feedback component is intended for interfaces that need an inline undo pill with a draining countdown ring that pauses on hover, form workflows, and support tools. Its implementation is provided as editable source so the final behavior and styling stay inside your project.
Technologies
Detected package dependencies: framer-motion.
Ana Wells
The homepage mock is ready for review
Dev Patel
Standup moved to 10:30 tomorrow
Mia Chen
Shipping notes for the 2.4 release
Installation
Usage
import { UndoPill } from "@/components/spectrumui/undo-pill"<UndoPill
open={open}
label="Message deleted"
onUndo={() => restore()}
onExpire={() => commit()}
/>API Reference
UndoPill
Renders a fully controlled pill with role="status" so it is announced politely to screen readers. Show it by setting open to true, then flip it back to false from onUndo and onExpire. Position it from outside via className or a wrapper element.
| Prop | Type | Default | Description |
|---|---|---|---|
*open | boolean | - | Controls whether the pill is shown. Fully controlled |
label | string | "Deleted" | Message shown inside the pill |
duration | number | 5 | Countdown length in seconds |
*onUndo | () => void | - | Fires when the Undo button is clicked or Escape is pressed while focus is within the pill |
*onExpire | () => void | - | Fires once when the countdown completes |
pauseOnHover | boolean | true | Pause the countdown while the pill is hovered or focused; it resumes on leave |
undoLabel | string | "Undo" | Text of the undo button |
className | string | - | Additional classes merged with the default pill styles |
Examples
Longer duration with pause on hover
8 second countdown — hover the pill to pause the countdown
Use cases
- interfaces that need an inline undo pill with a draining countdown ring that pauses on hover
- form workflows
- support tools
Features
- Copy-paste source that remains in your repository
- TypeScript source included with the component
- Tailwind CSS classes editable in the component source
- Animation implemented with Motion
- Reduced-motion handling present in the source
Accessibility
- The source includes ARIA attributes or roles; preserve them when customizing the component.
- The source includes keyboard event handling; verify it alongside pointer behavior.
- The source checks reduced-motion preferences or includes motion-reduce styles.
- Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.
Customization
- Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
- Use the documented className surface for local layout adjustments, then edit the source for structural changes.
- Adjust Motion transitions in the source and keep the reduced-motion behavior aligned with the final interaction.
Related components
Topic guides
See how this component fits into broader interface patterns, implementation decisions, and working examples.
Undo Pill FAQ
Is Undo Pill free to use in commercial projects?
Yes. The public Undo Pill source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.
How do I install Undo Pill?
Run npx shadcn@latest add @spectrumui/undo-pill. The page also exposes the source for manual installation.
Does Undo Pill require Motion?
Yes. Motion usage was detected in the documented source or registry dependencies for Undo Pill.
Does Undo Pill use shadcn/ui or Radix UI?
No shadcn/ui or Radix UI dependency was detected in the documented Undo Pill source.
Can I use Undo Pill in Next.js?
The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.
What accessibility checks should I run for Undo Pill?
The source includes ARIA markup, keyboard handlers, reduced-motion handling. Test the finished interface with keyboard and screen-reader workflows.