apps/docs/content/docs/en/react/components/(navigation)/disclosure.mdx
import { Disclosure } from '@heroui/react';
<ComponentPreview name="disclosure-basic" minHeight="440px" />
import { Disclosure } from '@heroui/react';
export default () => (
<Disclosure>
<Disclosure.Heading>
<Disclosure.Trigger>
<Disclosure.Indicator />
</Disclosure.Trigger>
</Disclosure.Heading>
<Disclosure.Content/>
</Disclosure>
)
<ComponentPreview name="disclosure-render-function" />
To customize the Disclosure component classes, you can use the @layer components directive.
Learn more.
@layer components {
.disclosure {
@apply relative;
}
.disclosure__trigger {
@apply cursor-pointer;
}
.disclosure__indicator {
@apply transition-transform duration-300;
}
.disclosure__content {
@apply overflow-hidden transition-all;
}
}
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
The Disclosure component uses these CSS classes (View source styles):
.disclosure - Base container styles.disclosure__heading - Heading wrapper.disclosure__trigger - Trigger button styles.disclosure__indicator - Chevron indicator styles.disclosure__content - Content container with animationsThe component supports both CSS pseudo-classes and data attributes for flexibility:
[data-expanded="true"] on indicator for rotation:focus-visible or [data-focus-visible="true"] on trigger:disabled or [aria-disabled="true"] on trigger[aria-hidden="false"] on content for visibility| Prop | Type | Default | Description |
|---|---|---|---|
isExpanded | boolean | false | Controls the expanded state |
onExpandedChange | (isExpanded: boolean) => void | - | Callback when expanded state changes |
isDisabled | boolean | false | Whether the disclosure is disabled |
children | ReactNode | RenderFunction | - | Content to render |
className | string | - | Additional CSS classes |
render | DOMRenderFunction<keyof React.JSX.IntrinsicElements, DisclosureRenderProps> | - | Overrides the default DOM element with a custom render function. |
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | RenderFunction | - | Trigger content |
className | string | - | Additional CSS classes |
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | Content to show/hide |
className | string | - | Additional CSS classes |
render | DOMRenderFunction<keyof React.JSX.IntrinsicElements, DisclosureContentRenderProps> | - | Overrides the default DOM element with a custom render function. |
When using the render prop pattern, these values are provided:
| Prop | Type | Description |
|---|---|---|
isExpanded | boolean | Current expanded state |
isDisabled | boolean | Whether disclosure is disabled |