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 box with a padded trigger built in, so a bare disclosure looks finished with no wrapper, and it grows with the content's height animation. Wrap it in a Card for a filled surface, or pass className="contents" to drop the box when nesting it inside one.

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.