Component guideEditable source

Collapsible

A single expandable region controlled by a disclosure button.

Original component docs
On this page4 sectionsBack to top

Use Collapsible for one independent section of optional content. Use Accordion for a related set of expandable sections. Visibility can be controlled by application state or left uncontrolled.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/collapsible.json

The Usage example additionally uses Button.

#Usage

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

export default function AdvancedOptions() {
  return (
    <Collapsible className="grid max-w-sm gap-3">
      <CollapsibleTrigger render={<Button variant="outline" />}>
        Advanced options
      </CollapsibleTrigger>
      <CollapsibleContent>
        <p>Additional workspace preferences belong here.</p>
      </CollapsibleContent>
    </Collapsible>
  );
}

#API reference

Prop / partPurposeDefault
open / onOpenChangeControlled expanded stateUncontrolled
defaultOpenInitial expanded statefalse
disabledPrevent togglingfalse
CollapsibleTrigger.renderButton compositionPrimitive button
CollapsibleContent.keepMountedPreserve closed content DOMfalse

#Accessibility

The trigger must describe the content it reveals. Keep it keyboard accessible and do not nest other controls inside it. Enter and Space toggle the panel. Do not hide required instructions or validation errors in a closed section without giving the user a clear way to discover them.