Collapsible

A collapsible panel controlled by a button.

API reference

Import the component and assemble its parts:

Anatomy
import { Collapsible } from '@base-ui-components/react/collapsible';

<Collapsible.Root>
  <Collapsible.Trigger />
  <Collapsible.Panel />
</Collapsible.Root>

Root

Groups all parts of the collapsible. Renders a <div> element.

PropTypeDefault
defaultOpen

boolean

false

open

boolean

undefined

onOpenChange

((open: boolean) => void)

undefined

disabled

boolean

false

className

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

undefined

render

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

undefined

Trigger

A button that opens and closes the collapsible 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

Panel

A panel with the collapsible 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-closed
data-starting-style
data-ending-style
CSS Variable
Description
--collapsible-panel-height
--collapsible-panel-width