Press and hold: a sweep crosses the button and the action fires when it reaches the far edge. Let go early and it springs back.
FreeWeb and Mobile2 variantsMotion
Preview
npx shadcn add @fetaui/hold-to-confirmPlayground
Kinds
Labels
Disabled
Kind
Icons animation
Motion
Installation
Terminal· bash
npx shadcn add @fetaui/hold-to-confirm
Kinds
Outline sits in a row. Solid is 288 px wide and 64 px high, for a final step.
Motion
Accessibility
- Progress is announced through a progressbar, in steps of 10.
- The accessible name stays the same while the label changes.
- The done label is announced when it fires.
Motion
- The sweep crosses the button over 1.6 s, slow at first, with a bright seam on its front edge.
- The button presses to 0.97 while held and springs back with a small pop when it fires.
- Letting go springs the sweep back.
- Labels draw in as they change.
- With reduced motion, or
animatedoff, the sweep still shows progress, with no press, pop or label motion.
Responsive behavior
- Solid fills the width on small screens.
Performance
- The sweep is one layer scaled on a motion value, so holding does not re-render on each frame. The percent updates in steps of 10.
- Nothing runs at rest: the sweep only animates while held or springing back.
- The fill animation stops on unmount and the reset timer clears.
Note for AI
Give your coding assistant the Markdown reference instead of screenshots.
- Import from @/components/fetaui/hold-to-confirm.
- Run the action in onComplete, which fires when the sweep reaches the far edge. There is no click action.
- Change label, progressLabel, doneLabel and icon together: the default says Hold to delete.
- The button resets 1.6 s after it completes, so guard against a second run yourself.
- The demo deletes nothing. Wire up onComplete.
Related
Slide To ConfirmComponentDrag the thumb across to confirm. Past 90% or a fast flick, it commits.Undo ButtonComponentAn action with a window to take it back.Alert DialogComponentA modal that interrupts with something important and waits for an answer.Tear ButtonComponentA ticket you confirm by tearing off its stub.ButtonComponentOne family for every action, with a label, optional icons and a shortcut key.