Accordion
Material 1 expansion panels for related details and lightweight editing.
Installation
pnpm dlx shadcn@latest add https://react-toolbox.io/r/accordion.jsonNew here? Set up your project first. Styles, fonts, and required components are included.
Usage
Use value and onValueChange to control the expanded values, or defaultValue for initial expansion. Both use arrays, even with a single panel. Add multiple to allow several open panels. Tab moves between triggers; Enter or Space toggles them. Headers default to h3; use render={<h2 />} for a different heading level. Put interactive controls inside the panel, not inside the trigger. Use keepMounted on a panel to preserve local form state while closed.
API reference
Key props and defaults. Full types and inline documentation are included with the source in material/accordion.
AccordionRoot
| Property | Type | Default |
|---|---|---|
defaultValue | Value[]The initially expanded item values for uncontrolled expansion. | — |
disabled | booleanDisable all triggers. | false |
multiple | booleanAllow more than one expanded panel at a time. | false |
onValueChange | (value: Value[], eventDetails: Primitive.Root.ChangeEventDetails) => voidCalled when an item requests expansion or collapse. | — |
value | Value[]The expanded item values. Use with onValueChange for controlled expansion. | — |
AccordionItem
| Property | Type | Default |
|---|---|---|
disabled | booleanDisable this item's trigger. | — |
value | Primitive.Item.Props['value']A unique value; supply one when using value or defaultValue on the root. | — |
AccordionPanel
| Property | Type | Default |
|---|---|---|
keepMounted | booleanKeep closed content mounted, for example to preserve local form state. | — |
Material guidelines
- Group lightweight editing tasks or related details into panels. Keep a concise summary visible when collapsed.
- Use 48px collapsed and 64px expanded header heights, with 24px horizontal padding and 16px separation around expanded panels. Put form controls and secondary actions inside the panel.