GitHub Stars

Collapsible

An interactive component which expands/collapses a panel.

Order #4189

Status Shipped

Installation

npx shadcn@latest add @fulldev/collapsible

Usage

import {
  Collapsible,
  CollapsibleContent,
  CollapsibleTrigger,
} 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>

Composition

Use the following composition to build a Collapsible:

Collapsible
├── CollapsibleTrigger
└── CollapsibleContent

Default Open

Use defaultOpen to render a collapsible expanded on first load.

<Collapsible defaultOpen>
  <CollapsibleTrigger>Toggle</CollapsibleTrigger>
  <CollapsibleContent>Content</CollapsibleContent>
</Collapsible>

Examples

Basic

Settings Panel

Use a trigger button to reveal additional settings.

Radius
Set the corner radius of the element.

File Tree

Use nested collapsibles to build a file tree.

Notes

  • Use Collapsible for progressive disclosure inside an existing layout.
  • Keep CollapsibleTrigger as the single control that opens and closes the content.
  • For stacked FAQ patterns with multiple items, prefer Accordion.

API Reference

See the GitHub source code for more information on props. See the data-slot docs for more information on interactivity.