Join our Discord Community

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.

Loading component...

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:

Loading component...

Controlled state management

When you need to manage the open/closed state externally:

Loading component...

Nested hierarchical content

Perfect for file trees, navigation menus, and organizational structures:

Loading component...

Multiple sections

Group related collapsibles for better organization:

Loading component...

API Reference

Collapsible

Contains all the parts of a collapsible. Root container that manages the open/closed state.

PropTypeDefaultDescription
defaultOpenbooleanfalseThe open state of the collapsible when initially rendered
openboolean-The controlled open state of the collapsible
onOpenChange(open: boolean) => void-Event handler called when the open state changes
disabledbooleanfalseWhen true, prevents the user from interacting with the collapsible
asChildbooleanfalseChange the default rendered element for the one passed as a child

CollapsibleTrigger

The button that toggles the collapsible.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child

CollapsibleContent

The component that contains the collapsible content.

PropTypeDefaultDescription
asChildbooleanfalseChange the default rendered element for the one passed as a child
forceMountbooleanfalseUsed to force mounting when more control is needed

Keyboard Navigation

KeyDescription
SpaceOpens/closes the collapsible
EnterOpens/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