Accordion
Stacked sections that expand to reveal content: FAQs, grouped settings.
- Content people need to compare side by side.
- A single disclosure: a Collapsible is lighter (Wave 3).
Install
Terminal
pnpm dlx shadcn@latest add @acme/accordionOr import from the package: import { Accordion } from '@acme/react'
Examples
Basic
accordion-basic.tsx
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from '@/components/ui/accordion'
const faqs = [
[
'Can I change plans later?',
'Yes. Upgrades apply immediately; downgrades apply at the next renewal.',
],
['Do you offer refunds?', 'Annual plans can be refunded within 30 days of purchase.'],
[
'Where is my data stored?',
'In the EU (Frankfurt) or the US (Virginia), chosen when you create the workspace.',
],
]
export default function AccordionBasic() {
return (
<Accordion className="max-w-lg">
{faqs.map(([q, a]) => (
<AccordionItem key={q}>
<AccordionTrigger>{q}</AccordionTrigger>
<AccordionContent>{a}</AccordionContent>
</AccordionItem>
))}
</Accordion>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| multiple | boolean | false | Allow several items open at once. |
| value / defaultValue | array | — | Open items. |
| AccordionTrigger.headingLevel | 2 | 3 | 4 | 5 | 6 | 3 | Heading level of each item header. |
Accessibility
| Key | Action |
|---|---|
| Enter / Space | Toggles the section |
| Arrow Up / Down | Moves between headers |
| Home / End | First / last header |
- Role
- heading > button (aria-expanded) + region
- You provide
- A headingLevel that fits the page outline.
- Built in
- Height animation is removed under reduced motion.
- WCAG 2.2 criteria
- 1.3.1, 2.1.1, 4.1.2
Don’t
- Hide the primary content of a page in an accordion.
Tokens
- color.border
- color.muted-foreground
- color.ring