Collapsible

Collapsible reveals one independent panel when controlled state, shared anatomy, or maintained motion adds value beyond native disclosure.

Overview and decision boundary

Use Collapsible for one independent disclosure when controlled state, shared anatomy, or maintained motion adds durable value.

Do not replace native details and summary when no shared state, motion, or anatomy is needed.

import { ChevronDown } from "@nerio-ui/adapters/icons";import { Icon } from "@nerio-ui/ui";import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "@nerio-ui/ui/client";<Collapsible>  <CollapsibleTrigger>    Recovery keys    <Icon aria-hidden icon={ChevronDown} />  </CollapsibleTrigger>  <CollapsiblePanel>    Generate a new set before revoking the current recovery keys.  </CollapsiblePanel></Collapsible>

Installation and imports

Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.

pnpm exec nerio add collapsibleimport { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "@nerio-ui/ui/client";

Usage

import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "@nerio-ui/ui/client";<Collapsible>  <CollapsibleTrigger>Recovery keys</CollapsibleTrigger>  <CollapsiblePanel>Generate and store recovery keys securely.</CollapsiblePanel></Collapsible>

Variants

PathUse
CollapsibleOne controlled or uncontrolled disclosure with maintained anatomy and motion.
details / summarySimple native disclosure with no shared abstraction requirement.

Anatomy

SlotPurpose
rootOwns one open state and the disabled boundary.
triggerNative button associated with the panel.
panelHidden content that unmounts when closed by default.

States

StateBehavior
ClosedPanel is removed by default, including interactive descendants.
OpenMeasured height and opacity reveal the complete content.
DisabledThe visible trigger cannot change state.
Reduced motionThe panel changes state immediately without travel.

Motion

  • Panel height uses the Base UI measured height variable and shared reveal tokens.
  • Opacity reinforces state without carrying essential information.
  • Reduced motion makes the state change immediate.

Accessibility

  • Uses the Base UI Collapsible primitive with a native type=button trigger by default.
  • The trigger owns aria-expanded and aria-controls while the panel owns the corresponding stable ID.
  • Closed panels are unmounted by default so hidden interactive descendants do not remain focusable; keepMounted and hiddenUntilFound preserve browser-hidden semantics.
  • Supports one controlled or uncontrolled open state and a disabled root without duplicating Base UI state.
  • Enter, Space, pointer, and touch activation toggle the panel while focus remains on the trigger.
  • Height and opacity motion use shared disclosure tokens and become immediate under reduced motion.
  • Use native details and summary when controlled state, maintained motion, or shared anatomy adds no durable value.

Review the shared responsibility and evidence boundaries in the Accessibility foundation alongside this component-specific contract. Use the Spacing & layout foundation for shared density, wrapping, overflow, reflow, and component-versus-product ownership guidance. The Color foundation, Typography foundation, and Localization foundation define the shared visual-role, text-resilience, direction, and locale boundaries used by component examples.

API

PropUse
open / defaultOpenControlled or uncontrolled open state.
onOpenChangeReceives the next state and cancellable Nerio event details.
disabledDisables the complete disclosure.
keepMounted / hiddenUntilFoundPreserves browser-hidden content for state or page search.

Implementation contract

ContractValue
Registry itemcollapsible installs 6 source files into the configured components directory.
Base UIcollapsible
Registry dependenciesNone.
Package dependencies@base-ui/react, clsx, react, tailwind-merge, tailwindcss

Styling contract

ContractValue
AuthoringComplete, statically detectable Tailwind CSS v4 recipes own component visuals.
ValuesSemantic and component --n-* variables remain the canonical customization layer.
OverridesCustomizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically.
Residual CSSOnly shared keyframes and scoped no-Preflight compatibility rules remain; there is no parallel visual selector layer.

Design notes

  • Collapsible owns one disclosure only; grouped expansion belongs to Accordion.
  • Content, persistence, fetching, analytics, and product workflow remain consumer-owned.

Do / do not

Do
Use one concise trigger for content that can safely leave the reading flow.
Do not
Wrap simple native disclosure or grouped sections in one oversized component.

Tokens

TokenControls
--n-disclosure-background / border / radiusDisclosure surface and boundary.
--n-disclosure-trigger-min-height / padding-inlineDensity-aware trigger geometry.
--n-disclosure-panel-padding-inline / foregroundPanel content rhythm and tone.
--n-disclosure-focus-ringInset trigger focus treatment.
--n-motion-reveal-duration / easingMeasured-height state transition.