Vesyl UI

Collapsible

A single trigger that shows or hides one region of content. Built on base-ui Collapsible — open state, ARIA wiring, and the data-panel-open / data-open hooks come for free.

Reach for Collapsible when you have one thing to reveal — an “Advanced options” block, an inline detail panel, a sidebar sub-menu. When you have a set of related sections that read as a group (FAQ, settings categories), use Accordion instead: it owns the shared open state and the single-vs-multiple-open policy across items. A Collapsible governs exactly one section and tracks nothing about its siblings.

Compose three parts: Collapsible (root, owns the open state), CollapsibleTrigger (the toggle), and CollapsibleContent (the region it reveals). The component is unstyled — bring your own trigger and panel chrome.

Basic

The root is uncontrolled and closed by default. Render the trigger as a Button via its render prop, and let the root’s data-open drive the chevron with group-data-open.

Open by default

Pass defaultOpen to start expanded while keeping the toggle uncontrolled — useful when the content is the point of the view and you only want to let people fold it away.

  • 2× Recycled mailer (small)
  • 1× Thermal label sheet
  • 1× Packing slip

With a DisclosureButton

DisclosureButton is the purpose-built trigger for disclosures: a compact ghost control whose chevron rotates automatically from the data-panel-open the trigger sets. Render it as the CollapsibleTrigger target and you track no state and write no rotation CSS.

Controlled

The root is uncontrolled by default — give it defaultOpen or nothing. To drive it yourself (e.g. to open the panel from elsewhere), pass open and onOpenChange.

const [open, setOpen] = useState(false);

<Collapsible open={open} onOpenChange={setOpen}>
  <CollapsibleTrigger render={(props) => <Button {...props}>Advanced shipping options</Button>} />
  <CollapsibleContent>…</CollapsibleContent>
</Collapsible>;

Reference

Collapsible

Root container. Renders a <div>. Extends base-ui Collapsible.Root props.

PropTypeDefaultDescription
defaultOpenbooleanfalseInitially open (uncontrolled)
openbooleanOpen state (controlled)
onOpenChange(open: boolean) => voidFires when the panel opens or closes
disabledbooleanfalseIgnore user interaction; the trigger can’t toggle
classNamestringMerged onto the root; sets data-open / data-closed

CollapsibleTrigger

The toggle. Extends base-ui Collapsible.Trigger props.

PropTypeDefaultDescription
renderReactElement | (props, state) => ElementRender as another element (e.g. Button, DisclosureButton); sets data-panel-open on it while open
childrenReactNodeTrigger content when not using render

CollapsibleContent

The region revealed by the trigger. Extends base-ui Collapsible.Panel props.

PropTypeDefaultDescription
childrenReactNodeThe collapsible content
classNamestringMerged onto the panel; sets data-open / data-closed