Hold to confirmPro
Press and hold to confirm destructive or important actions; letting go cancels.
Press and hold to confirm.Press and hold to confirm.
Let go early and it cancels.
When to use
- Destructive or expensive actions that shouldn't fire on a stray click: delete, release, wipe.
When not to use
- Frequent actions: holding every time is slow.
- Actions that need explanation: use a confirm dialog.
Installation
Usage
Import it from @/components/ui/hold-to-confirm after installing.
example.tsx
import { HoldToConfirm } from "@/components/ui/hold-to-confirm";
export function DeleteProject({ id }: { id: string }) {
return (
<HoldToConfirm tone="destructive" onConfirm={() => deleteProject(id)} doneLabel="Deleted">
Hold to delete
</HoldToConfirm>
);
}API reference
HoldToConfirm
A button that fills while held and confirms when full; releasing early drains it.
| Prop | Type | Default | Description |
|---|---|---|---|
| onConfirm | () => void | Promise<void> | – | Runs once the hold completes. |
| duration | number | 1400 | Hold time in ms. |
| holdingLabel / doneLabel | ReactNode | "Keep holding…" / "Done" | Labels while held and after. |
| resetAfter | number | 2200 | ms before returning to idle; 0 keeps the done state. |
| tone | "default" | "destructive" | "default" | Color. |
Keyboard interactions
| Keys | Action |
|---|---|
| Hold SpaceorEnter | Fill and confirm |
| Release | Cancel before it fills |
Accessibility
- Described by a hidden hint: "Press and hold to confirm."
- Confirmation is announced politely.
- Works with keyboard holds, not just pointers.
Motion
- The fill grows linearly over the duration; releasing drains it in 350ms.
- Labels swap with a short blur and slide; the button presses in slightly while held.
Responsive behavior
- At least 176px wide; touch holds work and long-press menus are suppressed.
Performance
- The fill is a motion value; nothing re-renders per frame.
Notes for AI
- Use for one action at a time; don't put several in a row.
This page as Markdown, for assistants and coding agents:
/components/hold-to-confirm/markdownThe full library index for assistants is at /llms.txt.
Lode222 doc pagesllms.txt