UI.MD

Collapsible

A disclosure that expands and collapses a section of content.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/collapsible.json

Usage

import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@/components/ui/collapsible"

Examples

Default

Collapsible ships its own surface: a bordered, clipped box with a padded trigger built in, so a bare disclosure looks finished with no wrapper. The box grows with the content's own height animation. For a filled/shadowed surface, wrap it in a Card; when nesting it headlessly inside another surface, pass className="contents" to drop the box.

API Reference

PropTypeDefaultDescription
openboolean-Controlled open state. Pair with onOpenChange.
defaultOpenbooleanfalseWhether the disclosure starts open when uncontrolled.
onOpenChange(open: boolean) => void-Called when the open state changes.
disabledbooleanfalseDisables the disclosure; the trigger dims and stops responding.