Skip to content
Sign upGet access
MicrointeractionsFocus accordionMenu

Focus accordion

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

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

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

PropTypeNotes
items{ id, question, answer }[]answer is a string or string[]
value / defaultValue / onValueChangestring | nullThe open item
titleReactNodeWith 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.