Introducing Motion-Primitives Pro - Advanced components and templates to help you build a website that stands out.

Accordion

A vertically stacked set of collapsible containers allowing users to toggle content visibility. Customize the animation effects with variants and transitions for expanding/collapsing the sections.

Examples

Accordion Basic

Accordion with icons

You can control transformations on elements inside AccordionTrigger using group-data-[expanded]:..... Here, we apply -rotate-180 to rotate the icon 180 degrees when its associated section is expanded.

Accordion custom variants

Installation

npx shadcn add "https://motion-primitives.com/c/accordion.json"

Component API

Accordion

PropTypeDefaultDescription
childrenReactNodeThe content elements of the accordion.
classNamestringOptional CSS class for styling the accordion container.
transitionTransitionTransition settings from motion for animation effects.
variants{ expanded: Variant; collapsed: Variant }Custom variants for expanded and collapsed states.
expandedValueReact.Key | nullControlled expanded value.
onValueChange(value: React.Key | null) => voidCallback function when the expanded value changes.

AccordionItem

PropTypeDefaultDescription
valueReact.KeyUnique identifier for controlling the accordion item state.
childrenReactNodeThe content elements of the accordion item.
classNamestringOptional CSS class for styling the accordion item container.

AccordionTrigger

PropTypeDefaultDescription
childrenReactNodeContent of the trigger, typically a string or formatted text.
classNamestringOptional CSS class for styling the trigger element.

AccordionContent

PropTypeDefaultDescription
childrenReactNodeThe content displayed when the accordion item is expanded.
classNamestringOptional CSS class for styling the content container.