Skip to content

Collapsible

A disclosure that shows and hides one panel from a trigger.

Max retries
3
Retry interval
1,000 ms
hero.tsx

Usage guidelines

  • Use Collapsible to hide secondary content, such as advanced settings or run details, behind a trigger that stays in place. Use Tabs to switch between peer panels, and Popover for content that floats above the page.
  • Name the trigger with its visible text. An icon-only trigger composes IconButton through render and takes the aria-label that IconButton requires.
  • CollapsibleTrigger draws only the focus ring. Compose Button or IconButton through render for a standard look, or style the native button for a full-width row.
  • Show the state on the trigger with the data-panel-open attribute, for example to rotate a chevron, instead of reading open in React.
  • CollapsiblePanel animates its height. Put padding on a child of the panel, not on the panel itself, so the closed panel collapses to zero height.
  • Several collapsibles open independently. Each section owns its own root and trigger.

Anatomy

tsx
tsx

Examples

Button trigger

Compose Button through render when the trigger reads as an action.

button-trigger.tsx

Icon button trigger

An icon-only trigger composes IconButton, which takes the accessible name through aria-label.

Run #1842 succeeded
icon-button-trigger.tsx

Hidden until found

hiddenUntilFound keeps the closed panel in the DOM with hidden="until-found", so find-in-page searches its text and opens the panel on a match. Search this page for "EPUB" and step to the match inside the closed panel to try it.

hidden-until-found.tsx

Keyboard

KeyAction
EnterorSpaceOpens or closes the panel. Focus stays on the trigger.

API reference

Collapsible

Groups a disclosure trigger and collapsible panel with animated height transitions. Renders a <div> element.

Base UI Collapsible.Root docs

Data attributes
AttributeDescription
data-open

Present when the collapsible is open.

data-closed

Present when the collapsible is closed.

data-starting-style

Present when the collapsible begins animating in.

data-ending-style

Present when the collapsible is animating out.

CollapsiblePanel

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

Base UI Collapsible.Panel docs

Data attributes
AttributeDescription
data-open

Present when the collapsible panel is open.

data-closed

Present when the collapsible panel is closed.

data-starting-style

Present when the panel begins animating in.

data-ending-style

Present when the panel is animating out.

CSS variables
VariableDescription
--collapsible-panel-height

Values: number

The collapsible panel's height.

--collapsible-panel-width

Values: number

The collapsible panel's width.

CollapsibleTrigger

Toggles the collapsible panel open or closed; carries only focus-ring styles so it can be composed via render with Button or IconButton. Renders a <button> element.

Base UI Collapsible.Trigger docs

Data attributes
AttributeDescription
data-panel-open

Present when the collapsible panel is open.