Skip to content

Collapsible

The Collapsible component provides a flexible way to show or hide content based on user interaction. It’s perfect for managing large amounts of information on a page, like FAQs, advanced settings, or detailed descriptions, by making content progressively disclosed.

Add the Collapsible component and its sub-components to your project using the OrbitUI CLI:

Terminal window
npx orbitkit@latest add collapsible

Import the Collapsible and CollapsibleContent components. Wrap your trigger element (like a Button or an <h4> with an inner Button) directly inside the Collapsible component and add the data-trigger attribute to it. The CollapsibleContent will contain the content that expands and collapses.

Toggle Collapsible

The Collapsible system consists of two main components, each with its own set of props:

The Collapsible component serves as the main wrapper for the expandable content system. It manages the open/closed state of its child CollapsibleContent.

PropTypeDefault
isOpenbooleanfalse
  • isOpen: Controls the visibility state of the content (true for open, false for closed).

This component accepts all the standard HTML attributes that a <div> element would.

The CollapsibleContent component contains the actual content that will be shown or hidden when the collapsible is toggled. This component accepts all the standard HTML attributes that a <div> element would.