Collapsible
A disclosure that shows and hides one panel from a trigger.
- Max retries
- 3
- Retry interval
- 1,000 ms
Usage guidelines
- Use
Collapsibleto hide secondary content, such as advanced settings or run details, behind a trigger that stays in place. UseTabsto switch between peer panels, andPopoverfor content that floats above the page. - Name the trigger with its visible text. An icon-only trigger composes
IconButtonthroughrenderand takes thearia-labelthatIconButtonrequires. CollapsibleTriggerdraws only the focus ring. ComposeButtonorIconButtonthroughrenderfor a standard look, or style the native button for a full-width row.- Show the state on the trigger with the
data-panel-openattribute, for example to rotate a chevron, instead of readingopenin React. CollapsiblePanelanimates 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
Examples
Button trigger
Compose Button through render when the trigger reads as an action.
Icon button trigger
An icon-only trigger composes IconButton, which takes the accessible name through aria-label.
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.
TXT, Markdown, PDF, HTML, EPUB, XLSX, DOCX, and CSV — up to 15 MB per file.
Keyboard
| Key | Action |
|---|---|
| EnterorSpace | Opens 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.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: CollapsibleRootState) => string | undefined) | No default | |
open | boolean | No default | |
defaultOpen | boolean | false | |
onOpenChange | ((open: boolean, eventDetails: CollapsibleRootChangeEventDetails) => void) | No default | |
disabled | boolean | false | |
render | ComponentRenderFn<HTMLProps, CollapsibleRootState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: CollapsibleRootState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
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.
| Prop | Type | Default | Details |
|---|---|---|---|
boolean | false | ||
keepMounted | boolean | false | |
className | string | ((state: CollapsiblePanelState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, CollapsiblePanelState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: CollapsiblePanelState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
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. |
| Variable | Description |
|---|---|
--collapsible-panel-height | Values: The collapsible panel's height. |
--collapsible-panel-width | Values: 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.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: CollapsibleTriggerState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, CollapsibleTriggerState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: CollapsibleTriggerState) => React.CSSProperties | undefined) | No default | |
nativeButton | boolean | true | |
| Attribute | Description |
|---|---|
data-panel-open | Present when the collapsible panel is open. |