A simple show/hide component with a trigger and content area. Useful for secondary information that doesn't need to be always visible.
import Collapsible from "@radui/ui/Collapsible"- Open state is controlled with open and onOpenChange, or uncontrolled with defaultOpen
- The trigger carries aria-expanded and aria-controls for the content
- hiddenUntilFound keeps closed content searchable with the browser's find
- Exposes data-state for CSS transitions, and keeps content mounted while one finishes
Import all parts of the component and piece them together.
The root collapsible container.
| Prop | Type | Default |
|---|---|---|
open | boolean | false |
defaultOpen | boolean | false |
disabled | boolean | false |
transitionDuration | number | 0 |
onOpenChange | function | — |
customRootClass | string | "" |
The button that toggles the collapsible open/closed.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | "" |
The content that is shown or hidden.
| Prop | Type | Default |
|---|---|---|
className | string | "" |
hiddenUntilFound | boolean | false |
forceMount | boolean | false |
| Shortcut | Description |
|---|---|
| Tab | Moves focus to the Collapsible.Trigger. |
| Space | Toggles the controlled content open or closed. |
| Enter | Toggles the controlled content open or closed. |
| Escape | When the content is open and focus is on the trigger, closes the content. |
| Reference | What Rad UI follows |
|---|---|
| Disclosure pattern | Uses a button trigger with aria-expanded and aria-controls to expose the content relationship. |