Skip to content

Collapsible

Show or hide a region of content with a controlled trigger — the primitive behind disclosures, FAQs, and inline expandables.

  • stable
  • since v0.1.0
  • 2.5 kB
  • data-display
  • disclosure

Trigger toggles aria-expanded and aria-controls; content stays in the DOM with hidden toggled so screen readers can re-announce it.

Preview
Open
tsx

Pass defaultOpen to render the content expanded on first paint without controlling state yourself.

Preview
Open
tsx

Pair open with onOpenChange to drive the state from the outside — handy when an external button or query param decides the open/close.

Preview
Open
tsx

Pass disabled on Collapsible to freeze the current open state and prevent the trigger from firing.

Preview
Open
tsx
PropTypeDefaultDescription
open
boolean
Controlled open state.
defaultOpen
boolean
Uncontrolled initial open state.
onOpenChange
((open: boolean) => void)
Fires with the next open state when toggled.
disabled
boolean
Disables the trigger and locks the panel in its current state.
  • The trigger sets aria-expanded and points aria-controls at the content region.
  • Content stays in the DOM with hidden toggled so assistive tech can re-announce it on every open.
  • Enter / Space on the focused trigger toggles the panel.
  • disabled propagates to the underlying <button> and ARIA — keyboard users skip past it.
  • The trigger renders as a real <button> (or your asChild host) so it inherits focus styles for free.
  • Use asChild on CollapsibleTrigger to wrap a Button and inherit Cynosure styling without losing the toggle behaviour.
  • Use defaultOpen for uncontrolled state; pair open + onOpenChange to control externally.
  • The Disclosure / DisclosureTrigger / DisclosureContent aliases point at the same component when the semantic name fits better (e.g. FAQs).
  • Animate the open/close transition with the data-state="open" and data-state="closed" attributes on CollapsibleContent.