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
idstring | undefinedgeneratedUnique identifier used to create the accordion part IDs.
idsElementIds | undefined—Overrides the generated IDs for individual parts.
valuestring[] | undefined—Expanded item values when the accordion is controlled.
defaultValuestring[] | undefined—Initially expanded item values.
multipleboolean | undefinedfalseAllows more than one item to be expanded.
collapsibleboolean | undefinedfalseAllows every item to be collapsed.
disabledboolean | undefinedfalseDisables 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.
lazyMountboolean | undefinedfalseMounts item content only after it is first expanded.
unmountOnExitboolean | undefinedfalseUnmounts item content when it is collapsed.

AccordionItem

PropTypeDefaultDescription
valuestring—Required unique value that identifies the item.
disabledboolean | undefinedfalsePrevents the item from being expanded.

Context, Hooks, and Types

ExportAPI
AccordionContextRender-prop component that exposes component state and actions.
AccordionItemContextRender-prop component that exposes the current item state.
AccordionRootProviderProvides an externally created API to the component tree.
useAccordionCreates or accesses the component API.
useAccordionContextReturns the nearest component API.
useAccordionItemContextReturns the nearest item state.
AccordionValueChangeDetailsType for the details object passed to the matching change callback.