Collapsible
Used to expand and collapse additional content.
Think of each component as a wheel in your app’s UI — smooth, connected, and full of potential. Build with harmony. Build withChakra UI.
Usage
import { Collapsible } from "@chakra-ui/react"<Collapsible.Root>
<Collapsible.Trigger>
<Collapsible.Indicator />
</Collapsible.Trigger>
<Collapsible.Content />
</Collapsible.Root>Examples
Initial Open
Use the defaultOpen prop to render the collapsible in an open state by
default.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Partial Height
Use the collapsedHeight prop to show a preview of the content when collapsed.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Disabled
Use the disabled prop to prevent the collapsible from being toggled.
disabled prop.Controlled
Use the open and onOpenChange props to control the collapsible state.
Store
An alternative way to control the collapsible is to use the RootProvider
component and the useCollapsible store hook.
useCollapsible hook and RootProvider allows you to access the collapsible store and control the state from anywhere in your component.Lazy Mounted
Use the unmountOnExit prop to make the content unmount when collapsed.
Guides
Content Padding
To prevent janky animations when the collapsible expands or collapses, apply
padding to the inner content element rather than directly on
Collapsible.Content to prevent visual stuttering as its animations.
DO THIS:
<Collapsible.Root>
<Collapsible.Trigger>Toggle</Collapsible.Trigger>
<Collapsible.Content>
<Box padding="4" borderWidth="1px">
{/* Content here */}
</Box>
</Collapsible.Content>
</Collapsible.Root>NOT THIS:
<Collapsible.Root>
<Collapsible.Trigger>Toggle</Collapsible.Trigger>
{/* ❌ Avoid applying padding directly to Content */}
<Collapsible.Content padding="4" borderWidth="1px">
{/* Content here */}
</Collapsible.Content>
</Collapsible.Root>Props
Root
| Prop | Default | Type |
|---|---|---|
lazyMount | false | booleanWhether to enable lazy mounting |
unmountOnExit | false | booleanWhether to unmount on exit. |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
unstyled | booleanWhether to remove the component's style. | |
defaultOpen | booleanThe initial open state of the collapsible when rendered. Use when you don't need to control the open state of the collapsible. | |
disabled | booleanWhether the collapsible is disabled. | |
ids | Partial<{ root: string; content: string; trigger: string }>The ids of the elements in the collapsible. Useful for composition. | |
onExitComplete | VoidFunctionThe callback invoked when the exit animation completes. | |
onOpenChange | (details: OpenChangeDetails) => voidThe callback invoked when the open state changes. | |
open | booleanThe controlled open state of the collapsible. |
Explorer
Explore the Collapsible component parts interactively. Click on parts in the
sidebar to highlight them in the preview.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Component Anatomy
Hover to highlight, click to select parts