apps/docs/content/docs/en/react/components/(navigation)/disclosure-group.mdx
import { DisclosureGroup } from '@heroui/react';
<ComponentPreview name="disclosure-group-basic" minHeight="580px" />
Import all parts and piece them together.
import {DisclosureGroup, Disclosure} from '@heroui/react';
export default () => (
<DisclosureGroup>
<Disclosure id="item1">
<Disclosure.Heading>
<Disclosure.Trigger>
<Disclosure.Indicator />
</Disclosure.Trigger>
</Disclosure.Heading>
<Disclosure.Content />
</Disclosure>
</DisclosureGroup>
)
You can control which disclosures are expanded with external navigation controls using the expandedKeys and onExpandedChange props.
<ComponentPreview name="disclosure-group-controlled" minHeight="580px" />
<RelatedShowcases component="DisclosureGroup" /> <RelatedComponents component="disclosuregroup" />import {
DisclosureGroup,
Disclosure,
DisclosureTrigger,
DisclosurePanel
} from '@heroui/react';
function CustomDisclosureGroup() {
return (
<DisclosureGroup className="border rounded-lg p-4 space-y-2">
<Disclosure id="first" className="border-b pb-2">
<DisclosureTrigger>Item 1</DisclosureTrigger>
<DisclosurePanel>Content 1</DisclosurePanel>
</Disclosure>
<Disclosure id="second">
<DisclosureTrigger>Item 2</DisclosureTrigger>
<DisclosurePanel>Content 2</DisclosurePanel>
</Disclosure>
</DisclosureGroup>
);
}
To customize the DisclosureGroup component classes, you can use the @layer components directive.
@layer components {
.disclosure-group {
@apply w-full;
/* Performance optimization */
contain: layout style;
}
}
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The DisclosureGroup component uses these CSS classes (View source styles):
.disclosure-group - Base container styles with layout containmentThe component supports both CSS pseudo-classes and data attributes for flexibility:
:disabled or [aria-disabled="true"] on entire group[data-expanded] states on child Disclosure items| Prop | Type | Default | Description |
|---|---|---|---|
expandedKeys | Set<Key> | - | The currently expanded items (controlled) |
defaultExpandedKeys | Iterable<Key> | - | The initially expanded items (uncontrolled) |
onExpandedChange | (keys: Set<Key>) => void | - | Handler called when expanded items change |
allowsMultipleExpanded | boolean | false | Whether multiple items can be expanded simultaneously |
isDisabled | boolean | false | Whether all disclosures in the group are disabled |
children | ReactNode | RenderFunction | - | Disclosure items to render |
className | string | - | Additional CSS classes |
When using the render prop pattern, these values are provided:
| Prop | Type | Description |
|---|---|---|
expandedKeys | Set<Key> | Currently expanded item keys |
isDisabled | boolean | Whether the group is disabled |