Skip to content

Migrating react-accordion 1.x → 2.0

Edit on GitHub

Version 2.0 requires @volvo-cars/css to be installed first.

2.0 is significantly smaller, with no dependency on vcc-ui or any CSS-in-JS library. It uses the native <details> and <summary> elements and is styled with static CSS. This gives you:

  • Built-in accessibility features from native elements
  • Automatic “Find in Page” support — the accordion opens when a browser search matches content inside it
  • Reduced HTML per item: from ~1KB / 11 elements down to ~0.4KB / 5 elements

The component was renamed to better reflect that it renders a <details> element and represents a single item in an accordion.

AccordionDetails (content wrapper) was removed

Section titled “AccordionDetails (content wrapper) was removed”

You no longer need a wrapper component around accordion content. Add your content as direct children of the new AccordionDetails instead.

Before

<Accordion>
<AccordionSummary>Summary</AccordionSummary>
<AccordionDetails>Content</AccordionDetails>
</Accordion>

After

<AccordionDetails>
<AccordionSummary>Summary</AccordionSummary>
<div className="pb-32">Content</div>
</AccordionDetails>

1.x prop2.0 equivalent
expandedopen
defaultExpandeddefaultOpen
onChangeonToggle
onAnimationEndonAnimationFinish
hideDividerclassName="border-b-0"
extendclassName
lazyRenderDetailsRemoved — see advanced usage docs
1.x prop2.0 equivalent
onInteractiononClick (prefer onToggle on AccordionDetails instead)
extendclassName

New in 2.0: iconPlacement prop to position the chevron to the left or right of the summary text.

Removed. Interactive content should not be placed within the accordion summary.

1.x prop2.0 equivalent
multipleexclusive (inverted logic — defaults to true). Can also be set to "until-lg" for mobile-only exclusive behaviour.

Removed. Use useAnimatedDetails instead for animated open/close behaviour.