# Slide to approve

Slide to confirm for payments, sends and deletes: ink follows the thumb, the words invert as it passes, and a short slide is thrown back.

Also called: slide to confirm, swipe to confirm, slide to unlock, swipe button.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Slide to pay. Drag the thumb: ink fills the track and the words invert as it passes. Let go early and it is thrown back; reach the end and it pays. Preview: https://chatcn.dev/preview/slide-to-approve-demo

Drag the thumb and the track fills in ink behind it; the words turn to paper as the ink passes over them. Let go short of the end and the thumb is thrown back with one small overshoot, the one place the kit allows one, because your hand threw it. A quick flick counts: the release projects where the throw would land. At the end the thumb becomes a run check while the action works, then lands on a check.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/slide-to-approve
```

## Usage

```tsx
import { SlideToApprove } from "@/components/ui/chatcn/pro/slide-to-approve"

<SlideToApprove
  label="Slide to pay €64.20"
  status={status}
  labels={{ working: "Paying", done: "Booked, ticket sent" }}
  onConfirm={pay}
/>
```

## Examples

### States

Example: Ready to done, and declined. The slider at rest, sending, sent with its receipt line, and the bank declining. Preview: https://chatcn.dev/preview/slide-to-approve-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `label` | `string` | The track text and the accessible name |
| `onConfirm` | `() => void` | On reaching the end, or on Enter |
| `status` | `"idle" | "working" | "done" | "error"` | Back to idle glides the thumb home |
| `labels` | `{ working?, done?, error? }` | Track text per later status |
| `threshold` | `number` | How far the thumb must travel, 0 to 1. Default 0.86 |
| `disabled` | `boolean` |  |

## Keyboard

- `Enter` or `End` on the focused thumb confirms.

## Accessibility

- `role="slider"` with the current status as `aria-valuetext`, so a screen reader hears Paying and then the result.
- Past either end the thumb resists like a rubber band instead of stopping dead.
- In a right to left layout the thumb travels the other way.

## Motion

- Drag writes the thumb, the ink `clip-path` and the label fade in the same frame. The release hands the measured velocity to the spring.
- Reduced motion: the thumb returns without the throw.

Source: https://chatcn.dev/docs/components/slide-to-approve