Shadcn Accordion
React accordion for FAQ and settings sections. Built with TypeScript and Tailwind CSS for Next.js using Base UI — one or many panels, keyboard navigation.
The shadcn accordion is a stacked list of headings. Click a heading and the panel under it opens. Use it for FAQs, settings groups, and any page where the labels are enough to scan and the details can wait.
Looking for a neobrutalism version for shadcn?
Same accordion, thicker borders. The NeoBrutalism accordion is the kit if you want that look.
Usage
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion"<Accordion defaultValue={["shipping"]}>
<AccordionItem value="shipping">
<AccordionTrigger>What are your shipping options?</AccordionTrigger>
<AccordionContent>Standard is 5–7 days. Express is 2–3.</AccordionContent>
</AccordionItem>
</Accordion>defaultValue is a string[]. One panel starts open. Add multiple if several can stay open. Every AccordionItem needs a unique value. Switch Base / Radix / Aria on the preview — the APIs differ, the file still lands in components/ui.
Composition
Basic
One item at a time. The first one starts open.
Multiple
multiple — the value is a string[]. Two groups can stay open while someone compares them.
Disabled
disabled on AccordionItem greys out that row. The trigger stays in the list so the gap is obvious.
Borders
border on the Accordion, px-4 on each item. Same keyboard model, just a box around the list.
Card
Wrap it in a Card when the accordion is a section, not the whole page.
RTL
Wrap with DirectionProvider and dir="rtl". Triggers use text-start so the chevron stays on the end.
API
Prop
Type
AccordionItem
Prop
Type
AccordionTrigger and AccordionContent take className.
Keyboard
| Key | Action |
|---|---|
Space / Enter | Toggle the focused trigger |
ArrowDown / ArrowUp | Move to the next / previous trigger |
Home / End | First / last trigger |
Tab | Leave the accordion |
Notes
Closed is hidden, not unmounted
Form fields inside a closed panel still submit with the form. Only render the fields while that value is open if they should not post.
Write the trigger as the question or the group name, not a sentence of explanation.
With other components
Second level in a panel
TabsKeep every section visible
CardFrame around the list
FormClosed fields still submit
SwitchControl in a settings row
SeparatorSplit groups in a panel
Questions
Related
Was this page helpful?
Sign in to leave feedback.
Manual
Install shadcn/ui by hand. Tailwind, aliases, cn(), components.json, then add a component from the shadcn.io registry with the official CLI.
Alert
React alert for success, errors, and inline notices on a page. Built with TypeScript and Tailwind CSS for Next.js using Base UI — role=alert, default and destructive.