Search documentation

Search the documentation and open a page.

A vertically stacked set of interactive headings that each reveal a section of content.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/accordion

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

PropTypeDefaultDescription
idstringgeneratedUnique identifier used to create the accordion part IDs.
idsElementIds—Overrides the generated IDs for individual parts.
valuestring[]—Expanded item values when the accordion is controlled.
defaultValuestring[][]Initially expanded item values.
multiplebooleanfalseAllows more than one item to be expanded.
collapsiblebooleanfalseAllows every item to be collapsed.
disabledbooleanfalseDisables interaction with every item.
orientation"horizontal" | "vertical""vertical"Sets the accordion's orientation and keyboard navigation.
onValueChange(details: { value: string[] }) => void—Runs when the expanded values change.
onFocusChange(details: { value: string | null }) => void—Runs when the focused item changes.
lazyMountbooleanfalseMounts item content only after it is first expanded.
unmountOnExitbooleanfalseUnmounts item content when it is collapsed.

AccordionItem

PropTypeDefaultDescription
valuestring—Required unique value that identifies the item.
disabledbooleanfalsePrevents the item from being expanded.

Context and Hooks

ExportAPI
useAccordion(props)Creates an accordion API from the state and behavior options above.
AccordionRootProviderAccepts that API through value and renders the root.
useAccordionContext()Returns the nearest accordion API.
useAccordionItemContext()Returns { expanded, focused, disabled } for the item.
AccordionContextRender-prop component that exposes the accordion API.
AccordionItemContextRender-prop component that exposes the current item state.
AccordionValueChangeDetailsType for the object passed to onValueChange.