AccordionnewNEW
AccordionnewNEW
A vertically stacked set of interactive headings that each reveal a section of content.
Usage
Accordion Props
Prop | Type | Default |
---|---|---|
type | "single" | "multiple" | "single" |
value | string | string[] | - |
defaultValue | string | string[] | - |
onValueChange | ((value: string | string[]) => void) | - |
collapsible | boolean | true |
disabled | boolean | false |
orientation | "horizontal" | "vertical" | "vertical" |
dir | "ltr" | "rtl" | "ltr" |
className | string | - |
Accordion.Item Props
Prop | Type | Default |
---|---|---|
value | string | - |
disabled | boolean | false |
className | string | - |
Accordion.Trigger Props
Prop | Type | Default |
---|---|---|
className | string | - |
Accordion.Content Props
Prop | Type | Default |
---|---|---|
forceMount | boolean | false |
className | string | - |
Examples
Single vs Multiple
The Accordion component supports two types of behavior:
- Single: Only one item can be open at a time
- Multiple: Multiple items can be open simultaneously
Controlled
You can control the accordion's state by providing value
and onValueChange
props.
Disabled Items
Individual accordion items can be disabled using the disabled
prop.
Custom Content
The accordion content can contain any React elements, allowing for rich layouts and complex content.
Accessibility
The Accordion component is built on top of Radix UI's Accordion primitive and follows the WAI-ARIA design pattern for accordions. It includes:
- Proper ARIA attributes for screen readers
- Keyboard navigation support
- Focus management
- Semantic HTML structure
Keyboard Navigation
- Space or Enter: Toggle the focused accordion item
- Arrow Down: Move focus to the next accordion item
- Arrow Up: Move focus to the previous accordion item
- Home: Move focus to the first accordion item
- End: Move focus to the last accordion item