Native Solid 2 fork. Original documentation and designs © WorkOS; historical posts retain their original context.
Accordion
A vertically stacked set of interactive headings that each reveal an associated section of content.
Features
Full keyboard navigation.
Supports horizontal/vertical orientation.
Supports Right to Left direction.
Can expand one or multiple items.
Can be controlled or uncontrolled.
Anatomy
Import all parts and piece them together.
API Reference
Root
Contains all the parts of an accordion.
Item
Contains all the parts of a collapsible section.
Header
Wraps an Accordion.Trigger. Use the asChild prop to update it to the appropriate heading level for your page.
Trigger
Toggles the collapsed state of its associated item. It should be nested inside of an Accordion.Header.
Content
Contains the collapsible content for an item.
Examples
Expanded by default
Use the defaultValue prop to define the open item by default.
Allow collapsing all items
Use the collapsible prop to allow all items to close.
Multiple items open at the same time
Set the type prop to multiple to enable opening multiple items at once.
Rotated icon when open
You can add extra decorative elements, such as chevrons, and rotate it when the item is open.
Horizontal orientation
Use the orientation prop to create a horizontal accordion.
Animating content size
Use the --radix-accordion-content-width and/or --radix-accordion-content-height CSS variables to animate the size of the content when it opens/closes:
Accessibility
Adheres to the Accordion WAI-ARIA design pattern.