# Hold Button

Press and hold to confirm, with a fill that drains back on early release and a drawn check on completion.

Install with

```bash
npx shadcn@latest add https://kokonutui.com/r/hold-button.json
```

## Installation

Hold Button is a free, open-source React component in the Kokonut UI [Buttons collection](/content/docs/buttons/index.html). Add it with the shadcn CLI, which copies the source into `components/kokonutui/hold-button.tsx`, so the code is yours to change.

```bash
npx shadcn@latest add @kokonutui/hold-button
```

Or add it by hand: install its packages, then copy the source from the code above into `components/kokonutui/hold-button.tsx`.

```bash
npm install class-variance-authority lucide-react motion
```

## Usage

```javascript
import HoldButton from "@/components/kokonutui/hold-button";

export default function Example() {
  return <HoldButton />;
}
```

## Props

| Prop              | Type      | Description                                          |
|-------------------|-----------|------------------------------------------------------|
| `children`        | `ReactNode` | Idle label. Defaults to a verb that matches the variant. |
| `holdDuration`    | `number`    | Default `1200`. How long (ms) the button has to be held.  |
| `holdingLabel`    | `ReactNode` | Default `"Keep holding"`. Label while holding.      |
| `completeLabel`   | `ReactNode` | Label once the hold completes.                        |
| `resetAfter`      | `number`    | Default `1800`. How long (ms) the complete state shows before resetting. 0 keeps it. |
| `onHoldComplete`  | `() => void` | Called once the button has been held for the full `holdDuration`. A short click or an early release never calls it.

Also takes every prop of `Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children">` and `VariantProps<typeof holdButtonVariants>`.

## Dependencies

| Needs                              | Version   | Comes from                             |
|------------------------------------|-----------|---------------------------------------|
| `class-variance-authority`         | `^0.7.1` | npm, installed by the CLI             |
| `lucide-react`                     | `^0.556.0` | npm, installed by the CLI             |
| `motion`                           | `^12.23.25` | npm, installed by the CLI             |
| `cn` from `lib/utils.ts`          |           | shadcn init                            |
| React                               | `19`      | Your app                              |
| Tailwind CSS                       | `4`      | Your app                              |

No provider, font or global CSS to set up: the file works as soon as it lands.

### Additional Buttons

- [Magnet Button](/content/docs/buttons/attract-button/index.html)  
  A call-to-action button wrapped in a field of iron filings that align to its magnetic field and lean toward your cursor.  
- [Command Button](/content/docs/buttons/command-button/index.html)  
  A button with its shortcut drawn as keycaps that sink as you press the real keys.
