PeakUI

DisclosureGroup

Container coordinating multiple expanded disclosures

Usage

import {Disclosure, DisclosureGroup} from "@peakui/react";

Anatomy

import {Disclosure, DisclosureGroup} from "@peakui/react";

export default () => (
  <DisclosureGroup>
    <Disclosure id="item1">
      <Disclosure.Heading>
        <Disclosure.Trigger>
          <Disclosure.Indicator />
        </Disclosure.Trigger>
      </Disclosure.Heading>
      <Disclosure.Content>
        <Disclosure.Body>Panel content</Disclosure.Body>
      </Disclosure.Content>
    </Disclosure>
  </DisclosureGroup>
);

Examples

Controlled

expandedKeys with onExpandedChange gives external control; useDisclosureGroupNavigation drives prev/next movement over the item ids.

Customization

Tailwind CSS

<DisclosureGroup className="w-full max-w-sm rounded-xl bg-surface-secondary p-2">
  <Disclosure id="billing"><!-- … --></Disclosure>
</DisclosureGroup>

Global CSS

@layer components {
  .disclosure-group {
    @apply w-full;

    /* Performance optimization */
    contain: layout style;
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The DisclosureGroup component uses these CSS classes (view source styles):

Base Classes

  • .disclosure-group - Base container styles with layout containment

Slots

  • [data-slot="disclosure-group"] - The group container

Interactive States

The component supports both CSS pseudo-classes and data attributes:

  • Disabled: [data-disabled] on the group disables every item
  • Expanded: each child Disclosure carries [data-expanded]

API Reference

DisclosureGroup

PropTypeDefaultDescription
expandedKeysIterable<Key>-The currently expanded items (controlled)
defaultExpandedKeysIterable<Key>-The initially expanded items (uncontrolled)
onExpandedChange(keys: Set<Key>) => void-Handler called when the expanded items change
allowsMultipleExpandedbooleanfalseWhether multiple items can be expanded simultaneously
isDisabledbooleanfalseWhether all disclosures in the group are disabled
childrenReactNode | ((values: DisclosureGroupRenderProps) => ReactNode)-Disclosure items to render, or a function of the render props
classNamestring | ((values: DisclosureGroupRenderProps) => string)-Additional classes, or a function of the render props
renderDOMRenderFunction<'div', DisclosureGroupRenderProps>-Replaces the rendered element with your own

Every other attribute of a <div> is accepted.

useDisclosureGroupNavigation

ArgumentTypeDescription
expandedKeysSet<string | number>The group's expanded keys
itemIdsstring[]The disclosure ids in group order
onExpandedChange(keys: Set<string | number>) => voidThe group's state setter
allowsMultipleExpandedbooleanKeeps previous items expanded while moving

Returns {currentIndex, isPrevDisabled, isNextDisabled, onPrevious, onNext}.

Render Props

PropTypeDescription
children(values: DisclosureGroupRenderProps) => ReactNodeReceives isDisabled, state
className(values: DisclosureGroupRenderProps) => stringSame values as children

On this page