# Suggestion fly

Starter prompts that go somewhere: the picked suggestion's words arc into the composer and unroll into the full prompt.

Also called: suggestion animation, prompt suggestion animation.

Example: Suggestions that go somewhere. Pick a starter prompt: the chip arcs into the composer and unrolls into the full prompt. Preview: https://chatcn.dev/preview/suggestion-fly-demo

Picking a starter prompt usually swaps the composer's text in place. Here the suggestion's own words lift off the list and travel on an arc to where the composer's text begins, then give way to the full prompt, which unrolls across the field from the start. The suggestion dims while its copy is away, so you can see where it came from.

## Installation

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

## Usage

```tsx
import { suggestionFly } from "@/components/ui/chatcn/suggestion-fly"

<button onClick={(e) =>
  suggestionFly({ from: e.currentTarget, to: textarea, onLand: () => setDraft(prompt) })
}>
  Plan a Lisbon weekend
</button>
```

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `from` | `HTMLElement` | The picked suggestion: its label text, or the whole row |
| `to` | `HTMLElement` | The composer's text field |
| `onLand` | `() => void` | Put the full prompt in the composer here |
| `duration` | `number` | Flight in ms. Default 460 |

## Accessibility

- The flying chip is an inert `aria-hidden` copy.
- Under reduced motion `onLand` runs at once and the prompt just appears.

## Motion

- An arc sampled into one keyframe list on `transform` and `opacity`, then a 420 ms `clip-path` unroll of the field, starting from the reading edge (right in a right to left layout).

Source: https://chatcn.dev/docs/components/suggestion-fly