---
title: "Hold Button"
description: "A button that runs its action only after you press and hold it. The fill grows while you hold and drains back if you let go early."
url: https://gelatinui.com/components/hold-button
markdown_url: https://gelatinui.com/components/hold-button.md
access: free
install: "npx shadcn@latest add @gelatin-ui/hold-button"
registry_item: https://gelatinui.com/r/hold-button.json
version: "2026-11-12"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Hold Button

> A button that runs its action only after you press and hold it. The fill grows while you hold and drains back if you let go early.

Page: https://gelatinui.com/components/hold-button

## When to use it

Best for: An action that is hard to undo, where a stray tap must not run it and a dialog is too slow.

- Use it for a delete, a send, or a swap that needs a clear, slow gesture.
- Return a promise from `onConfirm` to show pending, then done or error.
- Set `duration` near 600ms for an action you can undo and near 2000ms for one you cannot.

## When not to use it

- For a normal action that is easy to undo, use a [Button](https://gelatinui.com/components/button.md).
- For a gesture people drag along a track, use [Swipe to Confirm](https://gelatinui.com/components/swipe-to-confirm.md).
- For an action that needs a written reason or a second look, use an [Alert Dialog](https://gelatinui.com/components/alert-dialog.md).

## Notes for agents

- Pass the label as `children`. A function child gives each status (`idle`, `pending`, `done`, `error`) its own content; `null` keeps the built-in one.
- `onConfirm` runs once on a full hold. A promise keeps `pending` until it settles: it resolves to `done` and rejects to `error`.
- `resetAfter` goes back to `idle` after `done`. `actionsRef` gives `confirm()` and `reset()` from code.
- With `type="submit"`, a full hold submits the form; an invalid form shows its messages and ends in `error`.
- A click with no pointer (a screen reader) confirms at once, with the fill run in on the `sheet` clock.
- The gesture is the `useHold` hook (`#/hooks/use-hold`), so a custom element can hold too.

## Anatomy

```text
HoldButton
```

## API reference

### HoldButton

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` | "default" |  |
| `variant` | `"default" \| "destructive" \| "destructive-outline" \| "outline" \| "secondary"` | "default" |  |
| `duration` | `number` |  | A full hold in ms. Default 1500; at least 200. |
| `onHoldStart` | `function` |  | A press started to fill. |
| `onHoldCancel` | `function` |  | A press ended before the end: the fill drains. |
| `onConfirm` | `function` |  | The hold reached the end (or a screen reader click, or `actionsRef.current.confirm`): run the action. The name of the Swipe to Confirm prop. Return a promise to stay `pending` until it settles: it resolves to `done` and rejects to `error`. Show the reason of an error yourself (a Toast). |
| `status` | `ActionStatus` |  | The status (controlled). Set it from `onStatusChange`, or the fill drains. |
| `defaultStatus` | `ActionStatus` |  | The status at first (uncontrolled). |
| `onStatusChange` | `function` |  |  |
| `resetAfter` | `number` |  | Back to `idle` this many ms after `done` (an action that can run again). |
| `actionsRef` | `Ref` |  | Confirm or reset from code. |
| `haptics` | `boolean` |  | A 10ms vibration when the hold completes, where the browser has one (Android). Default true. |
| `children` | `ConfirmContent` |  | The label at rest ("Hold to delete"), with an icon if you like. The other statuses show a spinner, a check, and `statusText`. A function of the status gives every status its own content instead; where it returns `null`, that status keeps its built-in content. |
| `statusText` | `ConfirmStatusText` |  | The words of `pending`, `done`, and `error`. Defaults (English): "Confirming", "Confirmed", "Retry". |
| `glow` | `boolean` |  | A soft halo in the fill color that grows with the fill (`glow`, `@gelatin-ui/glow`). Default: `false`. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| HoldButton | `hold-button` | `data-current`, `data-glow` | `--hold-button-progress` | `glow`, `motion-timing`, `status-colors` |

## Usage

Put the action in `onConfirm`: it runs only after a full hold.

```tsx title="delete-project.tsx"
import { HoldButton } from "@/components/ui/hold-button";

export function DeleteProject({ onDelete }: { onDelete: () => void }) {
  return (
    <HoldButton variant="destructive" onConfirm={onDelete}>
      Hold to delete
    </HoldButton>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/hold-button
```

It adds 30 registry items: 26 files, 5137 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@xstate/react`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Button](https://gelatinui.com/components/button.md)
- [Spinner](https://gelatinui.com/components/spinner.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Button](https://gelatinui.com/components/button.md)
- [Swipe to Confirm](https://gelatinui.com/components/swipe-to-confirm.md)
- [Alert Dialog](https://gelatinui.com/components/alert-dialog.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Space, Enter | Hold: fills while held; a full hold runs the action. Let go early and the fill drains. |
| Escape | While held: stops the hold and drains the fill. |

## Motion

| Part | Motion |
| --- | --- |
| Hold | progress · the fill grows from the start side at one speed for `duration` |
| Let go early | indicator · the fill drains back from where it is |
| Reset or error | sheet · the full fill drains back to empty |
| Click with no hold | sheet · the fill runs in to full, then the action runs |
| Status text | fade · the label fades to the text of the new status |
