Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

useCollapsibleSections

Expanded state for several sections, with expand all and collapse all.

HooksLayout@gaudi/design-system/hooks/layout/use-collapsible-sectionsView in StorybookSource

Coordinates individual and bulk disclosure for settings pages, filter sidebars, FAQs and inspectors. The initial expansion is read once; onChange receives the expanded ids after each change. The pure reducer is exported too.

Usage

import { useCollapsibleSections } from '@gaudi/design-system/hooks';
const sections = useCollapsibleSections({ sections: ['profile', 'billing', 'privacy'], initialExpanded: ['profile'] });

Examples

Settings with expand and collapse all

Storybook

API

4 options
5 return values

Accessibility

Render each section with Collapsible or Accordion so triggers expose aria-expanded. Disable "Expand all" when everything is open rather than hiding it, so the controls do not move.

Notes

  • collapsibleSectionsReducer, createCollapsibleSectionsState and areAllSectionsExpanded are exported.