Hold to Confirm
Overview
A press-and-hold button that fills a progress ring before confirming destructive actions.
This action component is intended for interfaces that need a press-and-hold button that fills a progress ring before confirming destructive actions, SaaS workflows, and onboarding flows. Its implementation is provided as editable source so the final behavior and styling stay inside your project.
Technologies
Detected package dependencies: framer-motion, lucide-react.
acme-website
Production · last deployed 2h ago
Press and hold the button — release early to cancel
Installation
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.
| Prop | Type | Default | Description |
|---|---|---|---|
*onConfirm | () => void | - | Fires exactly once when the hold reaches completion |
duration | number | 1200 | How long the button must be held, in milliseconds |
label | string | "Hold to delete" | Idle label |
confirmedLabel | string | "Deleted" | Label shown after a completed hold |
icon | React.ReactNode | - | Replaces the default trash icon |
size | "sm" | "md" | "lg" | "md" | Visual size of the button |
resetDelay | number | 1500 | Milliseconds before resetting to idle after confirming; 0 keeps the confirmed state |
disabled | boolean | false | Disables pointer and keyboard interaction |
className | string | - | Additional classes merged with the default button styles |
Examples
Sizes and custom duration
Use cases
- interfaces that need a press-and-hold button that fills a progress ring before confirming destructive actions
- SaaS workflows
- onboarding flows
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
- Responsive Tailwind variants present in the source
- 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.
Hold to Confirm FAQ
Is Hold to Confirm free to use in commercial projects?
Yes. The public Hold to Confirm source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.
How do I install Hold to Confirm?
Run npx shadcn@latest add @spectrumui/hold-to-confirm. The page also exposes the source for manual installation.
Does Hold to Confirm require Motion?
Yes. Motion usage was detected in the documented source or registry dependencies for Hold to Confirm.
Does Hold to Confirm use shadcn/ui or Radix UI?
No shadcn/ui or Radix UI dependency was detected in the documented Hold to Confirm source.
Can I use Hold to Confirm 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 Hold to Confirm?
The source includes ARIA markup, keyboard handlers, reduced-motion handling. Test the finished interface with keyboard and screen-reader workflows.