A vertically stacked set of interactive headings that each reveal a section of content.
Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
Accordion └── AccordionItem ├── AccordionTrigger │ └── AccordionItemIndicator (optional) └── AccordionContent
Examples
Card
Loading...
Controlled
Loading...
Default
Loading...
Separated Items
Loading...
With Form Fields
Loading...
With Icons
Loading...
API Reference
Accordion
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | undefined | generated | Unique identifier used to create the accordion part IDs. |
ids | ElementIds | undefined | — | Overrides the generated IDs for individual parts. |
value | string[] | undefined | — | Expanded item values when the accordion is controlled. |
defaultValue | string[] | undefined | — | Initially expanded item values. |
multiple | boolean | undefined | false | Allows more than one item to be expanded. |
collapsible | boolean | undefined | false | Allows every item to be collapsed. |
disabled | boolean | undefined | false | Disables interaction with every item. |
orientation | "horizontal" | "vertical" | undefined | "vertical" | Sets the accordion's orientation and keyboard navigation. |
onValueChange | ((details: ValueChangeDetails) => void) | undefined | — | Runs when the expanded values change. |
onFocusChange | ((details: FocusChangeDetails) => void) | undefined | — | Runs when the focused item changes. |
lazyMount | boolean | undefined | false | Mounts item content only after it is first expanded. |
unmountOnExit | boolean | undefined | false | Unmounts item content when it is collapsed. |
AccordionItem
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Required unique value that identifies the item. |
disabled | boolean | undefined | false | Prevents the item from being expanded. |
Context, Hooks, and Types
| Export | API |
|---|---|
AccordionContext | Render-prop component that exposes component state and actions. |
AccordionItemContext | Render-prop component that exposes the current item state. |
AccordionRootProvider | Provides an externally created API to the component tree. |
useAccordion | Creates or accesses the component API. |
useAccordionContext | Returns the nearest component API. |
useAccordionItemContext | Returns the nearest item state. |
AccordionValueChangeDetails | Type for the details object passed to the matching change callback. |
Angular
React
Solid
Svelte
Vue