Undo Pill

An inline undo pill with a draining countdown ring that pauses on hover.

@spectrumui/undo-pill

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

Login to view commandCreate a free account to access the install command

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.

PropTypeDefaultDescription
*openboolean-Controls whether the pill is shown. Fully controlled
labelstring"Deleted"Message shown inside the pill
durationnumber5Countdown 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
pauseOnHoverbooleantruePause the countdown while the pill is hovered or focused; it resumes on leave
undoLabelstring"Undo"Text of the undo button
classNamestring-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