Collapsible
A section that expands and collapses to show or hide its content.
The free plan includes up to three projects, 1 GB of storage, and community support.
Usage
Collapsible is a single show/hide disclosure — one trigger controlling one panel. Reach for it for a "read more", an inline details section, or any one-off toggle; for a set of mutually-aware sections use Accordion instead. Compose it from three parts, all under @appica/ui-react/collapsible:
Collapsible— the root. Owns the open state (open/defaultOpen) and can bedisabled.CollapsibleTrigger— the button that toggles the panel. It exposesdata-panel-openanddata-disabledfor styling.CollapsibleContent— the panel, which animates its height open and closed. It publishes the--collapsible-panel-heightCSS variable that powers that animation.
The parts ship almost unstyled so the collapsible inherits your layout — the examples below add the card, chevron, and spacing.
Examples
Default
A trigger and a panel. The panel animates its height open and closed, and the leading chevron rotates a quarter-turn because the trigger carries data-panel-open while open. Pass defaultOpen to start expanded, as here.
File tree
Nest a Collapsible inside another Collapsible's content to build an expandable tree. Each folder is its own disclosure; files are plain rows. A recursive render keeps any depth tidy.
Settings panel
Reveal extra controls only when they're needed. A single radius sets every corner; the icon-button beside it expands a per-corner panel below. The icon swaps between a maximize and minimize glyph entirely from the root's data-open state — no JavaScript.
Show more
Because the trigger and panel are independent, the trigger can sit below the always-visible text as a "Show more / Show less" toggle, with the label following the open state.
Controlled
Drive the open state yourself with open + onOpenChange. Here an external button and the header share the same state, so either one toggles the panel.
Disabled
Add disabled to the root to lock the panel shut. The trigger drops out of the tab order and exposes data-disabled for styling.
Keep mounted
By default the panel unmounts when closed. Pass keepMounted to leave it in the DOM so the browser's find-in-page and search-engine crawlers can still reach the hidden text.
RTL
Every Appica UI component supports right-to-left layouts out of the box. Set the dir attribute on a container (commonly your <html> element) so CSS logical properties resolve correctly, and wrap your tree in DirectionProvider so direction-aware behavior follows the same direction.
The trigger and its panel align to the right, the panel's indent moves to the right via the logical ps-* padding, and the leading chevron mirrors to point toward the inline start. For setup details and caveats, see the RTL guide.
تشمل الخطة المجانية ما يصل إلى ثلاثة مشاريع، وذاكرة تخزين بسعة 1 غيغابايت، ودعم المجتمع.
API reference
Collapsible wraps Base UI's Collapsible. Each part forwards ref and its remaining props to the matching Base UI primitive, so anything it accepts works here — the tables below list the most common props. The panel exposes the --collapsible-panel-height CSS variable that powers the height animation. See the Base UI docs for the complete API.
Collapsible
The root. Renders a <div> and owns the open state.
CollapsibleTrigger
The toggle button. Renders a <button> with aria-expanded/aria-controls wired to the panel, and exposes data-panel-open / data-disabled.
CollapsibleContent
The animated panel. Renders a <div> and exposes data-open / data-closed.
Accessibility
CollapsibleTriggeris a real<button>witharia-expandedreflecting the state andaria-controlspointing at the panel, so assistive tech announces "expanded"/"collapsed".- Enter and Space toggle the panel while the trigger is focused; the trigger is reachable with Tab.
- A
disabledcollapsible removes the trigger from the tab order and marks itdata-disabledfor styling. - Any indicator icon (the chevron in these examples) is decorative — the trigger's text label carries the meaning.
- The panel's height animation honours
prefers-reduced-motion, collapsing instantly when the user prefers reduced motion.