Hold to Confirm

A press-and-hold button that fills a progress ring before confirming destructive actions.

@spectrumui/hold-to-confirm

acme-website

Production · last deployed 2h ago

Press and hold the button — release early to cancel

Installation

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

Usage

import { HoldToConfirmButton } from "@/components/spectrumui/hold-to-confirm"
<HoldToConfirmButton onConfirm={() => console.log("confirmed")} />

API Reference

HoldToConfirmButton

Renders a single button element. Holding it down with a pointer, Space or Enter fills the ring over duration milliseconds and fires onConfirm exactly once on completion. A polite live region announces the confirmation to screen readers.

PropTypeDefaultDescription
*onConfirm() => void-Fires exactly once when the hold reaches completion
durationnumber1200How long the button must be held, in milliseconds
labelstring"Hold to delete"Idle label
confirmedLabelstring"Deleted"Label shown after a completed hold
iconReact.ReactNode-Replaces the default trash icon
size"sm" | "md" | "lg""md"Visual size of the button
resetDelaynumber1500Milliseconds before resetting to idle after confirming; 0 keeps the confirmed state
disabledbooleanfalseDisables pointer and keyboard interaction
classNamestring-Additional classes merged with the default button styles

Examples

Sizes and custom duration