suiss/ui · Component
Accordion
A vertically stacked set of headings that each reveal a section of content.
Accordion is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Accordion wraps the accordion primitive of the chosen base. An Accordion holds one or more AccordionItem parts; each item pairs an AccordionTrigger with an AccordionContent panel. The trigger renders inside a heading element and shows a caret that flips between down and up as the panel opens and closes.
Use an accordion to shorten long pages of related content, such as FAQs or settings groups, where people only need one or a few sections at a time. For a single show-and-hide region, a collapsible is a lighter fit.
Installation
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
- Install the dependencies and add the
cnhelper:
- Copy the source into
components/ui/accordion.tsx:
- Update the import paths to match your project.
Usage
Give each AccordionItem a unique value. By default only one panel is open at a time; opening another closes the previous one. Set multiple on Accordion to let several panels stay open.
The open state is an array of item values. Use defaultValue (for example ["shipping"]) for uncontrolled use, or value with onValueChange to control it.
Examples
Filled
The filled variant places the items on a rounded bg-muted surface.
By default
Opens an item on first render with defaultValue.
Multiple
Keeps several panels open at once with multiple.
API Reference
Accordion
The root that groups items and manages which panels are open.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "filled" | "default" | Visual style. default is plain with dividers; filled adds a rounded bg-muted container. |
Also accepts the props of the primitive part it wraps.
AccordionItem
A single section that pairs a trigger with its panel, identified by value.
Also accepts the props of the primitive part it wraps.
AccordionTrigger
The button, inside a heading, that toggles its item's panel and shows the caret indicator.
Also accepts the props of the primitive part it wraps.
AccordionContent
The collapsible panel holding the item's content.
Also accepts the props of the primitive part it wraps.
Accessibility
- Each trigger is a
buttonwitharia-expandedreflecting its panel's state. - Triggers are wrapped in a heading element.
- Triggers are reachable with Tab;
EnterandSpacetoggle the focused panel. - Disabled triggers receive
aria-disabledand are dimmed withopacity-50.
Notes
- Styling hooks:
data-slot="accordion","accordion-item","accordion-trigger","accordion-trigger-icon"and"accordion-content". - The panel animates with
animate-accordion-downandanimate-accordion-upondata-openanddata-closed. classNameonAccordionContentapplies to the inner padded wrapper, not the animated panel.
Accordion groups AccordionItems, each with an AccordionTrigger and an AccordionContent panel. The root and items are Reanimated views with a layout transition, so items below move smoothly as a panel opens or closes, and the trigger's caret rotates as it opens.
The default variant draws items on the page background separated by hairlines. The filled variant puts the whole list on a rounded bg-muted surface, which suits grouped settings or FAQ cards.







