Focus accordion
An accordion where the answer comes into focus line by line.
On this page
Open a question and its answer resolves out of a blur a piece at a time while the other questions step back.
Open a question and its panel opens on a spring while the answer resolves a piece at a time, each one arriving out of a blur, and the other questions recede so the one you asked stays in front. The plus turns into a minus with a small overshoot. Close it and the lines blur away quickly as the panel settles shut.
Installation
Usage
import { FocusAccordion } from "@/components/ui/chatcn/focus-accordion"
<FocusAccordion title="Questions" items={[{ id: "spend", question: "Can it spend money?", answer: "Only up to your budget." }]} />A string answer is split into sentences; pass an array to choose the pieces, one per line.
Props
| Prop | Type | Notes |
|---|---|---|
items | { id, question, answer }[] | answer is a string or string[] |
value / defaultValue / onValueChange | string | null | The open item |
title | ReactNode | With the count beside it |
Accessibility
- Each question is a button with
aria-expandedcontrolling a labelled region; closed answers are inert.
Motion
- Panels spring open (230, 24) and shut (320, 34); pieces focus in 800 ms, 120 ms apart. Reduced motion: panels jump and text appears at once.