# Swipe reply

Swipe a message to reply, with a threshold you can see click.

Also called: swipe to reply.

Example: Swipe to reply, with a click you can see. Drag a message sideways and a reply arrow grows in behind it, its ring filling; at the line it fills blue and ticks forward. Let go past it and the reply opens. Preview: https://chatcn.dev/preview/swipe-reply-demo

Drag a message sideways and it gives less the further you go; behind it a reply arrow grows in, its ring filling as you pull. At the line the ring fills with colour and the arrow ticks forward. Let go past it and the bubble springs home with a little overshoot and the reply opens; short of it, it just springs home.

## Installation

```bash
npx shadcn@latest add https://chatcn.dev/r/swipe-reply.json
```

## Usage

```tsx
import { SwipeReply } from "@/components/ui/chatcn/swipe-reply"

<SwipeReply side="start" onReply={() => quote(message)}>
  <Bubble>{message.text}</Bubble>
</SwipeReply>
```

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `onReply` | `() => void` | Past the line, or Enter or R while focused |
| `side` | `"start" | "end"` | Theirs swipe right, yours left. Default start |
| `threshold` | `number` | Px. Default 56 |

## Keyboard

| Key | Action |
| --- | --- |
| `Enter` / `R` | Reply to the focused message |

## Accessibility

- The message is focusable and says how to reply.

## Motion

- A rubber band drag and a slightly underdamped spring home. Vertical drags pass through to scrolling.

Source: https://chatcn.dev/docs/components/swipe-reply