Collapsible
React collapsible component with smooth animations and keyboard navigation. Perfect for FAQs, navigation menus, and content sections that need to expand and collapse.
Need to save space but keep content accessible? Users expect to click and reveal more information without navigating away. Collapsible components work great for FAQs, navigation menus, and any content that benefits from progressive disclosure.
Built on Radix UI Collapsible with smooth animations and full accessibility support.
npx shadcn@latest add collapsible
Collapsible patterns that users recognize
FAQ and help sections
The most common pattern - questions that expand to show answers:
Controlled state management
When you need to manage the open/closed state externally:
Nested hierarchical content
Perfect for file trees, navigation menus, and organizational structures:
Multiple sections
Group related collapsibles for better organization:
API Reference
Collapsible
Contains all the parts of a collapsible. Root container that manages the open/closed state.
Prop | Type | Default | Description |
---|---|---|---|
defaultOpen | boolean | false | The open state of the collapsible when initially rendered |
open | boolean | - | The controlled open state of the collapsible |
onOpenChange | (open: boolean) => void | - | Event handler called when the open state changes |
disabled | boolean | false | When true, prevents the user from interacting with the collapsible |
asChild | boolean | false | Change the default rendered element for the one passed as a child |
CollapsibleTrigger
The button that toggles the collapsible.
Prop | Type | Default | Description |
---|---|---|---|
asChild | boolean | false | Change the default rendered element for the one passed as a child |
CollapsibleContent
The component that contains the collapsible content.
Prop | Type | Default | Description |
---|---|---|---|
asChild | boolean | false | Change the default rendered element for the one passed as a child |
forceMount | boolean | false | Used to force mounting when more control is needed |
Keyboard Navigation
Key | Description |
---|---|
Space | Opens/closes the collapsible |
Enter | Opens/closes the collapsible |
Collapsible best practices
What makes collapsibles feel natural and accessible:
- Use clear trigger text - "Shipping Information" instead of vague "More Details"
- Add visual indicators - Chevron icons that rotate to show state changes
- Keep content focused - Each collapsible should cover one topic or section
- Start with logical defaults - FAQ sections often start collapsed, navigation menus often start open
- Smooth animations matter - Users notice jarring expand/collapse transitions
- Group related content - Multiple collapsibles work well for organizing information
- Test keyboard navigation - Space, Enter, and Tab should all work properly
- Don't nest too deeply - More than 2-3 levels gets confusing fast
Checkbox
React checkbox component with three states, keyboard navigation, and form integration. Perfect for terms acceptance, settings toggles, and multi-select lists.
Combobox
React combobox with search, autocomplete, and keyboard navigation. Perfect for dropdowns with many options, user selection, and searchable interfaces.