Collapsible Component
An interactive component which expands/collapses a panel.
AsChild Pattern
Use AsChild to compose triggers with your own styled Button components.
Without AsChild
CollapsibleTrigger renders its own button with inline classes.
Hidden content revealed!
With AsChild
Button receives trigger behavior via TriggerContext.
Content using Button with AsChild!
Basic Usage
A simple collapsible with trigger and content.
Controlled Mode
Control the open state programmatically.
Disabled State
Disable interaction with the collapsible.
Accordion Style (Multiple Collapsibles)
Multiple collapsibles working independently.
With Icons and Badges
Enhance collapsibles with visual indicators.
Nested Collapsibles
Collapsibles can contain other collapsibles for hierarchical content.
This parent contains nested collapsibles.
With Smooth Animations
Add CSS transitions for smooth expand/collapse effects.
This content animates smoothly when expanding and collapsing.
CSS transitions create a polished user experience.
Accessibility Notes
Best practices for accessible collapsibles.
✓ Keyboard navigation: Trigger responds to Space and Enter keys.
✓ ARIA attributes: aria-expanded reflects the current state.
✓ Screen readers: Content uses region role and aria-hidden.
✓ Focus management: Focus remains on trigger after expanding/collapsing.
✓ Semantic HTML: Proper button elements for triggers.
API Reference
Collapsible
Open
Type: bool |
Default: false
Controls whether the collapsible is expanded.
OpenChanged
Type: EventCallback<bool>
Callback invoked when the open state changes.
Disabled
Type: bool |
Default: false
Prevents toggling when true.
CollapsibleTrigger
Class
Type: string?
Additional CSS classes for the trigger button.
CollapsibleContent
Class
Type: string?
Additional CSS classes for the content container.