Hold to confirm
A deliberate action, held for a moment: the ring fills, the label changes, and confirmation settles into a check.
Used forDestructive actionsPayments and transfersPublishing and deploysBulk actions
Install with the shadcn CLI
Older shadcn CLI, or a network that blocks ui.shadcn.com? Install by URL: shadcn add https://hairlineui.com/r/hold-to-confirm.json. More
Used in a block
All blocksTemplates
Need the whole page?
65 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
Destructive actions
Delete a project, a workspace or an account.
Payments and transfers
Send a payment or a payout that can’t easily be called back.
Publishing and deploys
Publish to production or send a campaign to everyone.
Bulk actions
Archive hundreds of records in one go.
What it handles for you
A confirm dialog interrupts the page, and people click through it without reading. Holding a button asks for intention without opening anything.
Intent without a dialog
Press and hold while a fine ring fills round the icon. The hold takes 1.1 seconds by default, between 0.3 and 5.
Letting go cancels
Releasing early, pressing Escape, leaving the button or losing focus resets the ring.
It runs once
The callback runs once after the hold, and a normal click never triggers it.
It shows the result
The label morphs, a spinner shows while the promise runs, then a drawn check or an alert.
Retry with another hold
If the callback fails, the button shows the error and the next hold tries again.
Works from the keyboard
Hold Space or Enter. Key repeat doesn’t restart the timer, and announcements live outside the button.
Overview
Give an important action a little intention without opening another dialog. Press and hold while a fine progress ring traces around the icon. Release early and it returns to rest. Cross the threshold and the same button moves through pending, success or error, with a morphing label and drawn check. The action runs once, and an error can be retried with another hold.
States
- hold
- The icon ring fills linearly over the configured threshold (1100ms by default). A short press does not confirm.
- release
- Early release, Escape, focus loss or pointer interruption cancels the hold. The ring resets over 240ms.
- pending
- After the threshold, the callback runs once. The label morphs and the progress icon gives way to a spinner.
- success / error
- A resolved callback draws a check; a rejected callback shows an alert and offers another hold. The button resets after 2200ms by default.
Usage
Depends on lucide-react, installed for you by the CLI along with the keyframes it needs.
Works with
Installs with it
Connect a deliberate action
The callback owns the actual operation. Reject its promise to show an error; the component never invents a successful result.
Props
- onConfirm
- () => void | Promise<void>
- Runs once after the hold threshold. Resolves to success or rejects to error.
- duration= 1100
- number
- Required hold in milliseconds, clamped to 300–5000.
- resetAfter= 2200
- number
- Delay before returning to idle. Set 0 to keep the result visible.
- labels
- Partial<Record<HoldStatus, string>>
- Labels for idle, holding, pending, success and error.
- onStatusChange
- (status: HoldStatus) => void
- Every change of state, e.g. to move something else in step with the hold.
- icon
- ReactNode
- Idle and holding icon. Defaults to a fingerprint.
- disabled= false
- boolean
- Disables the action and cancels an active hold.
Accessibility and motion
- Hold the pointer, Space or Enter to confirm. Key repeat does not restart the timer, and a normal click never triggers the callback.
- Releasing early, leaving the button, losing focus, Escape or a hidden browser tab cancels an incomplete hold. A completed action continues through its promise.
- State announcements live outside the button. The button retains focus while pending or showing its result.
- Reduced motion removes icon movement and spinning. The functional progress ring still communicates the hold duration.
- Use clear action labels and provide undo in your application where appropriate.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
The CLI also installs Text morph.
Source
Registry item: /r/hold-to-confirm.json


