docs/components/collapsible
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Collapsible content in a vertical stack.
PreviewCode
Total visits
22.3%10.1%6.8%1.4%
Details
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/collapsible
Collapsible
├── CollapsibleTrigger
└── CollapsibleContent
import {
Collapsible,
CollapsibleTrigger,
CollapsibleContent
} from "@/components/ui/collapsible";
<Collapsible>
<CollapsibleTrigger>Can I use this in my project?</CollapsibleTrigger>
<CollapsibleContent>
Yes. Free to use for personal and commercial projects. No attribution
required.
</CollapsibleContent>
</Collapsible>
Use the open and onOpenChange props to control the collapsible state programmatically.
PreviewCode
Expand
❌
PreviewCode
Disabled Collapsible
Collapsibles can be nested to create hierarchical structures.
PreviewCode
Getting started
We'll help you get started
View details
Use the collapsedHeight prop to show a portion of the content when collapsed.
PreviewCode
Read more
This is the first paragraph of content. When collapsed, only a portion of this content will be visible.
This is the second paragraph. It will be hidden when the collapsible is in its collapsed state.
This is the third paragraph. Expand the collapsible to see all the content.
This is the fourth paragraph. The collapsedHeight prop controls how much content is visible when collapsed.
Collapse (cannot be focused when collapsed)
Accessibility Notice
Interactive elements (links, buttons, inputs) within the collapsed area automatically become inaccesible to prevent keyboard navigation to hidden content.
Root component. Controls expand/collapse state and animation.
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | false |
onOpenChange | ({ open }: OpenChangeDetails) => void | - |
collapsedHeight | string | - |
className | string | - |
Toggles expand/collapse on click. Use asChild for custom trigger elements.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Holds the content that expands and collapses. Animated by default.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Chevron or icon that rotates to indicate open/closed state.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
For a complete list of props, see the Ark UI documentation.
[
Previous page
Clipboard ](/docs/components/clipboard)[
Next page
Color Picker ](/docs/components/color-picker)
On This Page
InstallationAnatomyUsageControlledStatesDisabledExamplesNestedPartial CollapseAPI ReferenceCollapsibleCollapsibleTriggerCollapsibleContentCollapsibleIndicator