Suggestion fly
Starter prompts that go somewhere: the picked suggestion's words arc into the composer and unroll into the full prompt.
On this page
Pick a starter prompt: the chip arcs into the composer and unrolls into the full prompt.
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
Usage
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-hiddencopy. - Under reduced motion
onLandruns at once and the prompt just appears.
Motion
- An arc sampled into one keyframe list on
transformandopacity, then a 420 msclip-pathunroll of the field, starting from the reading edge (right in a right to left layout).