Motion UIComponentsComponent

Accordion

Springy height-morph accordion panels that fold open with a blur-in on the copy.

npx shadcn@latest add @motion/accordion

API reference

Components

<Accordion />

Accordion root: Base UI open state plus optional deep-linking.

multiple?

boolean = false

Whether multiple rows can be open at once. Defaults to false.

defaultValue?

string[]

Values open on first render (uncontrolled).

value?

string[]

Controlled open values.

onValueChange?

(value: string[]) => void

Called with the next open values whenever a row is toggled.

deepLink?

boolean = false

Open and scroll to the row matching the URL fragment. Defaults to false.

className?

string

Merged onto the container element.

children?

ReactNode

The AccordionItem rows.

<AccordionItem />

One disclosure row keyed by value.

value

string

Stable value for this row and its deep-link anchor id.

className?

string

Merged onto the row element.

children?

ReactNode

The row's AccordionTrigger and AccordionPanel.

<AccordionTrigger />

Accessible trigger with indicator slot.

children?

ReactNode

The trigger label.

indicator?

ReactNode

Open/closed indicator after the label. Defaults to <AccordionChevron />.

className?

string

Merged onto the <button>.

headingLevel?

2 | 3 | 4 | 5 | 6 = 3

Heading level wrapping the button. Defaults to 3.

inset?

boolean = false

Use inset focus ring inside overflow-hidden containers. Defaults to false.

<AccordionPanel />

Height-morph collapsible panel with fold mask and inner blur-in.

children?

ReactNode

The disclosed content.

className?

string

Merged onto the inner content wrapper.

<AccordionChevron />

Chevron indicator that rotates with row open state.

open?

boolean

Force open/closed state. Omit to read from the enclosing row.

className?

string

Merged onto the indicator.

<AccordionPlusMinus />

Plus/minus indicator that morphs with row open state.

open?

boolean

Force open/closed state. Omit to read from the enclosing row.

className?

string

Merged onto the indicator.

Hooks

useAccordionHash

Deep-link hook: opens row matching URL hash on mount and hashchange.

useAccordionHash(options: UseAccordionHashOptions): void

onMatch

(id: string) => void

Called with the matched fragment id on mount and on every hashchange.

ids?

readonly string[]

Restrict matches to these ids. Omit to honour any fragment on the page.

enabled?

boolean = true

Turn the listener off. Defaults to true.

Functions

nextOpenIds

Toggle one value in the open set; under single-open, opening one closes the rest.

nextOpenIds(current: string[], value: string, singleOpen: boolean): string[]

revealOpenIds

Ensure value is open (deep-link reveal, never closes).

revealOpenIds(current: string[], value: string, singleOpen: boolean): string[]

Related examples