Skip to content

Stepped Accordion

Edit on GitHub

Displays content sequentially, reducing overwhelm when there's too much to show at once.

@volvo-cars/css v3.3.1@volvo-cars/react-accordion v2.4.0

The Stepped Accordion organizes content into collapsible sections displayed vertically with a connecting left border. Only one section can be open at a time, guiding users through sequential information.

Step one
Content for step one.
Step two
Content for step two.
Step three
Content for step three.
Show codeHide code
import {
SteppedAccordion,
SteppedAccordionDetails,
SteppedAccordionSummary,
} from '@volvo-cars/react-accordion';
import { useState } from 'react';
export function BasicSteppedAccordion() {
const [currentStep, setCurrentStep] = useState(0);
const steps = [
{ id: 0, title: 'Step one', content: 'Content for step one.' },
{ id: 1, title: 'Step two', content: 'Content for step two.' },
{ id: 2, title: 'Step three', content: 'Content for step three.' },
];
return (
<SteppedAccordion>
{steps.map(({ id, title, content }) => (
<SteppedAccordionDetails
key={id}
open={currentStep === id}
onToggle={() => setCurrentStep(id)}
>
<SteppedAccordionSummary>{title}</SteppedAccordionSummary>
<div className="pb-8 px-24 text-secondary">{content}</div>
</SteppedAccordionDetails>
))}
</SteppedAccordion>
);
}

The component uses three parts:

  • SteppedAccordion – Container that provides the vertical layout and left border
  • SteppedAccordionDetails – Wraps each step, controls open state via the open prop
  • SteppedAccordionSummary – The clickable header for each step

The Stepped Accordion is always controlled. Track the current step with state and update it via the onToggle callback. An open step cannot be closed directly. Opening another step closes the current one.

const [currentStep, setCurrentStep] = useState(0);
<SteppedAccordionDetails
open={currentStep === 0}
onToggle={() => setCurrentStep(0)}
>

Add content inside each step after the summary. Use the standard padding classes for consistent spacing. See a richer scenario in Examples.

SteppedAccordionSummary renders a <summary> element, inheriting the same native <details>/<summary> semantics as Accordion. Key consumer responsibilities:

  • Accessible name: provide clear step header text. If using icons or non-text indicators, add aria-label or aria-labelledby.
  • No interactive children in summary: <summary> has an implicit button role. Nesting links, buttons, or other interactive elements inside SteppedAccordionSummary is invalid.
  • Expand/collapse via keyboard: handled natively (Space / Enter on <summary>). Ensure users can tab in and out without getting trapped.
  • Locked open step: the currently open step’s summary is marked aria-disabled and removed from the tab order, so it can’t be closed by clicking or tabbing to itself. Open a different step to close it.
  • Consistent labeling: use the same naming pattern for step headers across your interface.
  • Target size: keep the header’s clickable area at least 40px tall.
PropTypeRequiredDefault
classNamestring--
onClickMouseEventHandler<HTMLDivElement>--
onMouseOverMouseEventHandler<HTMLDivElement>--
onMouseOutMouseEventHandler<HTMLDivElement>--
styleCSSProperties--
PropTypeRequiredDefault
openboolean✓-
Whether the details are open.
hiddenboolean--
idstring--
titlestring--
dirstring--
langstring--
slotstring--
translate"yes" | "no"--
styleCSSProperties--
onClickMouseEventHandler<HTMLDetailsElement>--
onPointerEnterPointerEventHandler<HTMLDetailsElement>--
onPointerMovePointerEventHandler<HTMLDetailsElement>--
onPointerDownPointerEventHandler<HTMLDetailsElement>--
onPointerUpPointerEventHandler<HTMLDetailsElement>--
onPointerLeavePointerEventHandler<HTMLDetailsElement>--
childrenReactNode✓-
The content of the accordion. The first child should be the `AccordionSummary` component.
classNamestring--
Custom class name, merged with existing classes.
onToggle((open: boolean) => void)--
Called when the accordion is toggled.
onAnimationFinish((open: boolean) => void)--
Called when the toggle animation is finished.
PropTypeRequiredDefault
hiddenboolean--
idstring--
titlestring--
dirstring--
langstring--
slotstring--
translate"yes" | "no"--
styleCSSProperties--
onFocusFocusEventHandler<HTMLElement>--
onBlurFocusEventHandler<HTMLElement>--
onClickMouseEventHandler<HTMLElement>--
onKeyDownKeyboardEventHandler<HTMLElement>--
onKeyUpKeyboardEventHandler<HTMLElement>--
onPointerEnterPointerEventHandler<HTMLElement>--
onPointerMovePointerEventHandler<HTMLElement>--
onPointerDownPointerEventHandler<HTMLElement>--
onPointerUpPointerEventHandler<HTMLElement>--
onPointerLeavePointerEventHandler<HTMLElement>--
childrenReactNode✓-
The label of the summary. Should not contain interactive elements.
iconReactNode--
The icon to display.
iconPlacement"start" | "end"--
The placement of the icon - before or after the label.
iconAlignment"top" | "center"--
The vertical alignment of the icon.
classNamestring--
Custom class name, merged with existing classes.