Accordion

A set of collapsible panels with headings.

API reference

Import the component and assemble its parts:

Anatomy
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.

PropTypeDefault
defaultValue

any[]

undefined

value

any[]

undefined

onValueChange

((value: any[]) => void)

undefined

hiddenUntilFound

boolean

false

openMultiple

boolean

true

disabled

boolean

false

loop

boolean

true

orientation

"horizontal" | "vertical"

'vertical'

className

string | ((state: State) => string)

undefined

keepMounted

boolean

false

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-disabled

Item

Groups an accordion header with the corresponding panel. Renders a <div> element.

PropTypeDefault
value

any

undefined

onOpenChange

((open: boolean) => void)

undefined

disabled

boolean

false

className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-open
data-disabled
data-index

A heading that labels the corresponding panel. Renders an <h3> element.

PropTypeDefault
className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-open
data-disabled
data-index

Trigger

A button that opens and closes the corresponding panel. Renders a <button> element.

PropTypeDefault
className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-panel-open
data-disabled

Panel

A collapsible panel with the accordion item contents. Renders a <div> element.

PropTypeDefault
hiddenUntilFound

boolean

false

className

string | ((state: State) => string)

undefined

keepMounted

boolean

false

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-open
data-disabled
data-index
data-starting-style
data-ending-style
CSS Variable
Description
--accordion-panel-height
--accordion-panel-width