Components / Buttons
Hold to Confirm
A button you press and hold to confirm. A fill sweeps across, perfect for destructive actions.
Confirmed 0 times
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/hold-button.tsx. - 3
Use it
example.tsx"use client"; import { useState } from "react"; import { HoldButton } from "@/components/ui/hold-button"; export default function HoldButtonDemo() { const [deleted, setDeleted] = useState(0); return ( <div className="flex flex-col items-center gap-3"> <HoldButton onConfirm={() => setDeleted((n) => n + 1)} confirmedLabel="Deleted ✓"> Hold to delete </HoldButton> <p className="text-xs text-zinc-500">Confirmed {deleted} time{deleted === 1 ? "" : "s"}</p> </div> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Button label. |
| holdDuration | number | 1.5 | Seconds to hold. |
| onConfirm | () => void | — | Called when the hold completes. |
| confirmedLabel | ReactNode | "Done!" | Label shown briefly after confirming. |