Installation
npx shadcn@latest add @pixeldosa/faq-sectionRequires `cn` at `@/lib/utils`. Use unique ids for each question. Native disclosures are independent and allow multiple answers to remain open simultaneously.
Usage
<FAQSection
title="Questions, answered"
items={[
{ id: "trial", question: "Can I try it first?", answer: "Yes, start with the free plan." },
]}
/>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | — | Section heading. |
description | string | — | Optional introduction. |
items | FAQItem[] | — | Questions and React-node answers with stable ids. |
density | "comfortable" | "compact" | "comfortable" | Spacing preset. |
className | string | — | Extra section classes. |
why it's built this way
Engineering Notes
Uses the native details/summary disclosure pattern rather than recreating accordion state and keyboard semantics. It supports browser-native keyboard operation and independent open states, with no runtime dependency or forced single-open behavior. Answers remain React nodes so consumers can include links or structured details.
how it moves, and when it doesn't
Motion Notes
The plus indicator rotates using the instant motion token only to reflect open state; the answer itself appears through the browser's native disclosure behavior. Under prefers-reduced-motion the indicator transition is disabled while its orientation and the answer state still communicate the change.