# Focus accordion

An accordion where the answer comes into focus line by line.

Also called: animated accordion, faq accordion.

Example: An answer that comes into focus. Open a question and its answer resolves out of a blur a piece at a time while the other questions step back. Preview: https://chatcn.dev/preview/focus-accordion-demo

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

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

## Usage

```tsx
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-expanded` controlling 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.

Source: https://chatcn.dev/docs/components/focus-accordion