# Length drag

An answer you make shorter or longer by hand, with a handle that unfolds or folds away its sentences.

Also called: answer length, shorten answer.

> 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: Answers by the inch. Drag the handle under the answer: held back sentences unfold into place, lit for a moment; drag up and the least important fold away. Preview: https://chatcn.dev/preview/length-drag-demo

Under the answer sits a handle. Drag it down and the sentences that were held back unfold into place, lit for a moment so you see what was added; drag it up and the least important ones fold away while the paragraph closes around what is left. The answer keeps its order at every length. Give each sentence a rank: 1 is essential.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/length-drag
```

## Usage

```tsx
import { LengthDrag } from "@/components/ui/chatcn/pro/length-drag"

<LengthDrag sentences={[{ text, rank: 1 }, ...]} value={length} onValueChange={setLength} />
```

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `sentences` | `{ text, rank }[]` | Higher ranks drop first |
| `value` / `onValueChange` | `number` | How many ranks show |
| `step` | `number` | Pixels of drag per step. Default 22 |

## Keyboard

| Key | Action |
| --- | --- |
| `ArrowDown` / `ArrowRight` | Longer |
| `ArrowUp` / `ArrowLeft` | Shorter |
| `Home` / `End` | Shortest or longest |

## Accessibility

- A vertical `role="slider"` read as "4 of 7 sentences".

## Motion

- New sentences arrive with an accent tint that fades over 1.1 s; leaving ones fade 200 ms; the paragraph height eases 280 ms.
- Reduced motion: sentences swap in place.

Source: https://chatcn.dev/docs/components/length-drag