Collapsible

An interactive component that expands and collapses a section of content.

Installation

$ npx shadcn@latest add "/r/collapsible.json"

Usage

Uncontrolled

Use defaultOpen for an uncontrolled collapsible.

This is expanded by default.

Props

Collapsible

PropTypeDefaultDescription
openboolean-The controlled open state.
defaultOpenbooleanfalseThe initial open state when uncontrolled.
onOpenChange(open: boolean) => void-Callback when the open state changes.
disabledbooleanfalseWhether the collapsible is disabled.

CollapsibleTrigger

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto the child element.
classNamestring-Additional CSS classes.

CollapsibleContent

PropTypeDefaultDescription
classNamestring-Additional CSS classes.