Accordion
Single or multiple panels with spring height animation. Closed content stays in the DOM for SEO.
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger,} from "@/components/ui/accordion";export function Faq() { return ( <Accordion type="single" collapsible defaultValue="a"> <AccordionItem value="a"> <AccordionTrigger>Is it accessible?</AccordionTrigger> <AccordionContent> Yes, keyboard and screen reader friendly. </AccordionContent> </AccordionItem> </Accordion> );}<Accordion>
Controlled (value + onValueChange) or uncontrolled (defaultValue).
children*ReactNodeAccordionItems.collapsiblebooleansingle only: allow closing the open panel.
defaultValuestring | string[]Open at first render (uncontrolled): an item, or items when
type="multiple".onValueChange((value: string) => void) | ((value: string[]) => void)Called with the open item ("" when it closes), or every open item when
type="multiple".type"single" | "multiple""single": one panel at a time. "multiple": independent panels.
valuestring | string[]Controlled open item ("" = none), or items when
type="multiple".
| Prop | Type | Default |
|---|---|---|
children*
| ReactNode | — |
collapsiblesingle only: allow closing the open panel. | boolean | — |
defaultValueOpen at first render (uncontrolled): an item, or items when | string | string[] | — |
onValueChangeCalled with the open item ("" when it closes), or every open item when | ((value: string) => void) | ((value: string[]) => void) | — |
type"single": one panel at a time. "multiple": independent panels. | "single" | "multiple" | — |
valueControlled open item ("" = none), or items when | string | string[] | — |
<AccordionItem>
children*ReactNodeAccordionTriggerandAccordionContent.value*stringUnique id within the Accordion, matched by
value/defaultValue.
| Prop | Type | Default |
|---|---|---|
children*
| ReactNode | — |
value*Unique id within the Accordion, matched by | string | — |
<AccordionTrigger>
children*ReactNodeQuestion or heading text.
asdefault"h3""h2" | "h3" | "h4" | "h5" | "h6"Wrapping heading level; match the page outline (default h3).
| Prop | Type | Default |
|---|---|---|
children*Question or heading text. | ReactNode | — |
asWrapping heading level; match the page outline (default h3). | "h2" | "h3" | "h4" | "h5" | "h6" | "h3" |
<AccordionContent>
Stays mounted when closed (inert, height 0) so content remains crawlable.
children*ReactNodePanel content; stays in the HTML while closed.
| Prop | Type | Default |
|---|---|---|
children*Panel content; stays in the HTML while closed. | ReactNode | — |
* required. Every component also takes className.