Skip to contents

Collapsible

A collapsible panel controlled by a button.

View as Markdown

Anatomy

Import the component and assemble its parts:

Anatomy

API reference

Root

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

defaultOpenbooleanfalse
Description

Whether the collapsible panel is initially open.

To render a controlled collapsible, use the open prop instead.

Type
Default
false
openboolean
Name
Description

Whether the collapsible panel is currently open.

To render an uncontrolled collapsible, use the defaultOpen prop instead.

Type
onOpenChangefunction
Description

Event handler called when the panel is opened or closed.

Type
disabledbooleanfalse
Description

Whether the component should ignore user interaction.

Type
Default
false
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type

Collapsible.Root.PropsHide

Re-Export of Root props as CollapsibleRootProps

Collapsible.Root.StateHide

Collapsible.Root.ChangeEventReasonHide

Collapsible.Root.ChangeEventDetailsHide

Trigger

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

nativeButtonbooleantrue
Description

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

Type
Default
true
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-panel-open

Present when the collapsible panel is open.

AttributeDescription
data-panel-open

Present when the collapsible panel is open.

Collapsible.Trigger.PropsHide

Re-Export of Trigger props as CollapsibleTriggerProps

Collapsible.Trigger.StateHide

Panel

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

hiddenUntilFoundbooleanfalse
Description

Allows the browser’s built-in page search to find and expand the panel contents.

Overrides the keepMounted prop and uses hidden="until-found" to hide the element without removing it from the DOM.

Type
Default
false
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
keepMountedbooleanfalse
Description

Whether to keep the element in the DOM while the panel is hidden. This prop is ignored when hiddenUntilFound is used.

Type
Default
false
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
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 is animating in.

data-ending-style

Present when the panel is animating out.

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 is animating in.

data-ending-style

Present when the panel is animating out.

--collapsible-panel-height

The collapsible panel’s height.

--collapsible-panel-width

The collapsible panel’s width.

CSS VariableDescription
--collapsible-panel-height

The collapsible panel’s height.

--collapsible-panel-width

The collapsible panel’s width.

Collapsible.Panel.PropsHide

Re-Export of Panel props as CollapsiblePanelProps

Collapsible.Panel.StateHide