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
openbooleanNoneControlled open state. Pair with onOpenChange.
defaultOpenbooleanfalseWhether the disclosure starts open when uncontrolled.
onOpenChange(open: boolean) => voidNoneCalled when the open state changes.
disabledbooleanfalseDisables the disclosure; the trigger dims and stops responding.
openbooleanControlled open state. Pair with onOpenChange.
defaultOpenboolean = falseWhether the disclosure starts open when uncontrolled.
onOpenChange(open: boolean) => voidCalled when the open state changes.
disabledboolean = falseDisables the disclosure; the trigger dims and stops responding.