Skip to content
Sign upGet access
MicrointeractionsSuggestion flyMenu

Suggestion fly

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

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

$ pnpm dlx 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

PropTypeNotes
fromHTMLElementThe picked suggestion: its label text, or the whole row
toHTMLElementThe composer's text field
onLand() => voidPut the full prompt in the composer here
durationnumberFlight 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).