Accordion
A set of collapsible panels with headings.
API reference
Import the component and place its parts the following way:
import { Accordion } from '@base-ui-components/react/accordion';
<Accordion.Root>
<Accordion.Item>
<Accordion.Header>
<Accordion.Trigger />
</Accordion.Header>
<Accordion.Panel />
</Accordion.Item>
</Accordion.Root>
Root
Groups all parts of the accordion.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
defaultValue | array | undefined | |
disabled | boolean | false | |
hiddenUntilFound | boolean | false | |
keepMounted | boolean | false | |
loop | boolean | true | |
onValueChange | (value) => void | undefined | |
openMultiple | boolean | true | |
orientation | 'horizontal' | 'vertical' | 'vertical' | |
render | | React.ReactElement | undefined | |
value | array | undefined |
Attribute | Description | |
---|---|---|
data-disabled | Present when the accordion is disabled. |
Item
Groups an accordion header with the corresponding panel.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
disabled | boolean | false | |
onOpenChange | (open) => void | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-disabled | Present when the accordion item is disabled. | |
data-index | Indicates the index of the accordion item. | |
data-open | Present when the accordion item is open. |
Header
A heading that labels the corresponding panel.
Renders an <h3>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-disabled | Present when the accordion item is disabled. | |
data-index | Indicates the index of the accordion item. | |
data-open | Present when the accordion item is open. |
Trigger
A button that opens and closes the corresponding panel.
Renders a <button>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-disabled | Present when the accordion item is disabled. | |
data-panel-open | Present when the accordion panel is open. |
Panel
A collapsible panel with the accordion item contents.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
hiddenUntilFound | boolean | false | |
keepMounted | boolean | false | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-disabled | Present when the accordion item is disabled. | |
data-ending-style | Present when the panel is animating out. | |
data-index | Indicates the index of the accordion item. | |
data-open | Present when the accordion panel is open. | |
data-starting-style | Present when the panel is animating in. |
CSS Variable | Description | |
---|---|---|
--accordion-panel-height | The accordion panel's height. | |
--accordion-panel-width | The accordion panel's width. |