Accordion
Accordion stacks sections under headings that people press to show or hide the content.
<Accordion multiple defaultValue={["shipping"]}> <AccordionItem value="shipping"> <AccordionTrigger>Shipping</AccordionTrigger> <AccordionPanel>…</AccordionPanel> </AccordionItem></Accordion>An accordion stacks sections one under the other. Each section has a heading that people press to show or hide its content. By default only one section is open at a time, and opening another closes it. Set multiple to let several sections stay open.
Use an accordion when a page has several sections and people usually need only one or two of them, such as a list of questions and answers or groups of settings. Use Tabs when people switch between views of one thing, and use NavTree for navigation with nested levels.
Each heading is as tall as a Button of the same size, and its label underlines under the pointer. The chevron points toward the reading direction while the section is closed and turns down while it is open. The text in a panel starts under the heading's label, so the two line up.
The accordion draws only the thin lines between its sections, with no box around them. Put it in a Card when the sections need an edge. size sets the headings and the panel text, and if you leave it unset, the accordion uses the size of the nearest Theme.
Each heading is a real heading element with a button inside it, so a screen reader lists the sections with the other headings on the page. Set headingLevel to match your page outline; the default is 3. People press Tab to move between headings and Enter or Space to open or close one, and the button announces whether its section is open.
Set hiddenUntilFound on a panel if you want the browser's find-in-page to open a closed section that contains a match.
- Tabs when people look at one section at a time.
Topics
Every symbol this component exports, grouped by the job it does. Each one carries the props it declares; each one has an anchor of its own.
Stacking the sections
| Prop | Type | What it does |
|---|---|---|
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
size? | "1" | "2" | "3" | "4" | The size step of the accordion, from 1 to 4. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
AccordionItem
One section, which holds a trigger and a panel. Its value is the name that the root's value and defaultValue arrays use
| Prop | Type | What it does |
|---|---|---|
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
Opening and closing one
AccordionTrigger
The heading of the section. It renders a heading element at the level you set, with a button inside it that is as tall as a Button of the same size
| Prop | Type | What it does |
|---|---|---|
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
headingLevel? | 2 | 3 | 4 | 5 | 6 | The heading level of the trigger, from 2 to 6. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
AccordionPanel
The content of the section, which shows while the section is open. Its text starts under the heading's label and matches the accordion's size
| Prop | Type | What it does |
|---|---|---|
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
- A horizontal orientation — Sections placed side by side need a different keyboard model and a different layout, so the accordion is always a vertical stack. Use
Tabsfor side-by-side views. toneandemphasis— The headings carry no meaning that a colour could add, and no section is more important than the others. If some panel text needs a colour, settoneon aTextinside the panel.- An icon slot or a custom chevron — The chevron is the one disclosure icon used everywhere in the system, including
NavTree. A different icon here would give people a second symbol for the same action. - A border or background of its own — The accordion draws only the lines between its sections, so it fits inside whatever surface holds it. Put it in a Card when the sections need an edge.