Installation
Usage
Props
Disclosure
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | Required. Must contain DisclosureHeading and DisclosureContent. |
variant | "default" | "contained" | "default" | Changes the styling on the component. |
state | DisclosureStateReturn | - | Provide the Disclosure state from useDisclosureState for controlled usage. |
visible | boolean | - | Control whether the disclosure is expanded (controlled mode). |
animated | boolean | true | Enable animation when expanding/collapsing. |
element | string | "DISCLOSURE" | Overrides the default element name for custom styling. |
DisclosureHeading
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | Required. The heading text. |
as | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | - | Required. The HTML heading level. |
variant | HeadingProps["variant"] | - | Required. The visual style of the heading. |
disabled | boolean | false | Disable the disclosure toggle. |
element | string | "DISCLOSURE_HEADING" | Overrides the default element name for custom styling. |
DisclosureContent
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | Required. The content to show/hide. |
element | string | "DISCLOSURE_CONTENT" | Overrides the default element name for custom styling. |
Examples
Default Disclosure
Contained Variant
Disabled Disclosure
Controlled Disclosure
Initially Expanded
Multiple Disclosures
Hooks
useDisclosureState
Returns state for controlling the disclosure programmatically.Accessibility
- Uses proper ARIA attributes (
aria-expanded,aria-controls) - Keyboard accessible (Space and Enter keys toggle)
- Focus management follows best practices
- Screen readers announce expansion state
- Chevron icon indicates interactive nature and current state
- Proper heading hierarchy for document structure
Best Practices
Do:
- Use headings that clearly describe the content
- Maintain proper heading hierarchy (h1 → h2 → h3)
- Group related disclosures together
- Use the contained variant when you need visual separation
Don’t:
- Don’t nest disclosures deeply (keep it to 2 levels max)
- Don’t use for navigation (use Sidebar or Tabs instead)
- Don’t hide critical information that users need immediately
When to Use
Use Disclosure when:
- You have content that can be progressively disclosed
- Building FAQ sections
- Creating expandable settings panels
- Organizing long-form content into scannable sections
Use Tabs instead when:
- Content sections are mutually exclusive
- Users need to switch between different views
Use Accordion instead when:
- You need only one section open at a time
- Content is part of a wizard or stepped process