---
title: "Swipe to Confirm"
description: "A track with a knob that you drag to the end to confirm an action that is hard to undo, such as a payment. It shows pending, done, and error."
url: https://gelatinui.com/components/swipe-to-confirm
markdown_url: https://gelatinui.com/components/swipe-to-confirm.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/swipe-to-confirm"
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Swipe to Confirm

> A track with a knob that you drag to the end to confirm an action that is hard to undo, such as a payment. It shows pending, done, and error.

Page: https://gelatinui.com/components/swipe-to-confirm

## When to use it

Best for: An action that is hard to undo, where a stray tap must not run it, such as a payment.

- Use it for a payment, a transfer, or a delete that needs a clear gesture.
- Return a promise from `onConfirm` to show pending, then done or error.
- Use `tone="destructive"` for a delete and `tone="success"` for a payment.

## 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 step that needs a written reason or a second look, use an [Alert Dialog](https://gelatinui.com/components/alert-dialog.md).

## Notes for agents

- Compose `SwipeToConfirmThumb` and `SwipeToConfirmLabel` in `SwipeToConfirm`. The label names the knob; without a label, give the knob an `aria-label`.
- A release past `threshold` (default 0.9) confirms. Enter and Space on the knob confirm with no drag.
- `onConfirm` may return a promise: it resolves to `done` and rejects to `error`. Show the reason of an error yourself.
- The label and the knob take a function child that answers per status: `idle`, `pending`, `done`, `error`.
- `resetAfter` goes back to `idle` after `done`. `disabled` stops the drag and the keys.
- `driverRef` gives a `DragDriver` (`pickUp`, `carry`, `drop`, `putBack`): a staged scene or a test slides the knob through the same threshold rules as a finger.

## Anatomy

```text
SwipeToConfirm
├─ SwipeToConfirmRootProvider (0..n)
├─ SwipeToConfirmThumb (0..n)
└─ SwipeToConfirmLabel (0..n)
```

## API reference

### SwipeToConfirm

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "lg" \| "xl"` |  |  |
| `tone` | `"destructive" \| "neutral" \| "success"` |  |  |
| `children` | `ReactNode` |  |  |
| `onConfirm` | `function` |  | Runs when the knob reaches the end (a release past the threshold, Enter, Space, or a `swipe.confirm` the app sends to the actor). Return a promise to show `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 knob goes back. |
| `defaultStatus` | `ActionStatus` |  | The status at first (uncontrolled). |
| `onStatusChange` | `function` |  |  |
| `disabled` | `boolean` |  | No drag, no key; the knob leaves the Tab order. |
| `threshold` | `number` |  | The share of the travel (0 to 1) that a release must reach to confirm. Default 0.9. |
| `resetAfter` | `number` |  | Back to `idle` this many ms after `done` (a control that can run again). |
| `glow` | `boolean` |  | A soft halo in the tone color that grows with the fill (`glow`, `@gelatin-ui/glow`). Default: `false`. |
| `driverRef` | `Ref<DragDriver \| null>` |  | Drives a slide from code (`DragDriver`, no item): a staged scene or a test grabs the knob, carries it, and lets go, and the release rules (the threshold) confirm or send it back. |

### SwipeToConfirmThumb

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `children` | `ConfirmContent` |  | The icon at rest (default: a chevron that points to the end). A function of the status gives each status its own icon; where it returns `null`, the status keeps its built-in icon (the spinner of `pending`, the check of `done`, the chevron). |

### SwipeToConfirmLabel

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `ConfirmContent` |  | The text at rest ("Slide to pay"). The other statuses show `statusText`. A function of the status gives every state its own text instead ("Slide to pay", "Paying", "Paid", "Payment failed. Slide to try again"). A change fades the old text out and the new one in. |
| `statusText` | `ConfirmStatusText` |  | The text of `pending`, `done`, and `error` for a plain `children` text. Defaults (English): "Confirming", "Confirmed", "Could not confirm. Retry". Pass the words of your language. |
| `shimmer` | `boolean` | false | A band of light that sweeps across the text (`@gelatin-ui/shimmer`), not when `done`. |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| SwipeToConfirm | `swipe-to-confirm` | `data-disabled`, `data-dragging`, `data-glow`, `data-status` | `--swipe-to-confirm-opacity`, `--swipe-to-confirm-x` | `glow`, `hit-area`, `motion-timing`, `status-colors` |
| SwipeToConfirmRootProvider | `swipe-to-confirm` | `data-disabled`, `data-dragging`, `data-glow`, `data-status` | `--swipe-to-confirm-opacity`, `--swipe-to-confirm-x` | `glow`, `hit-area`, `motion-timing`, `status-colors` |
| SwipeToConfirmThumb | `swipe-to-confirm-thumb` |  | `--swipe-to-confirm-opacity`, `--swipe-to-confirm-x` |  |
| SwipeToConfirmLabel | `swipe-to-confirm-label` |  | `--swipe-to-confirm-x` |  |

## Usage

Drag the thumb to the end, or press Enter on it, to confirm. Return a promise from `onConfirm` to show the busy state until it ends.

```tsx title="send-payment.tsx"
import { SwipeToConfirm, SwipeToConfirmLabel, SwipeToConfirmThumb } from "@/components/ui/pro/swipe-to-confirm";

async function sendPayment() {
  await fetch("/api/payments", { method: "POST" });
}

export function SendPayment() {
  return (
    <SwipeToConfirm onConfirm={sendPayment}>
      <SwipeToConfirmThumb />
      <SwipeToConfirmLabel>Slide to send</SwipeToConfirmLabel>
    </SwipeToConfirm>
  );
}
```

## 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-pro/swipe-to-confirm
```

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

## Built on

- [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)
- [Alert Dialog](https://gelatinui.com/components/alert-dialog.md)
- [Progress](https://gelatinui.com/components/progress.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter, Space | On the knob: confirms with no drag. |

## Motion

| Part | Motion |
| --- | --- |
| Release at the end | indicator · the knob slides to the end and the action runs |
| Release before the end | sheet · the knob slides back to the start |
| Label swap | fade · the label text fades to the text of the new status |
| Press | press · the knob steps to the pressed color |
