Stepped Accordion
Displays content sequentially, reducing overwhelm when there's too much to show at once.
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.
Show 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> );}Composition
Section titled “Composition”The component uses three parts:
SteppedAccordion– Container that provides the vertical layout and left borderSteppedAccordionDetails– Wraps each step, controls open state via theopenpropSteppedAccordionSummary– The clickable header for each step
Controlled state
Section titled “Controlled state”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)}>Rich content
Section titled “Rich content”Add content inside each step after the summary. Use the standard padding classes for consistent spacing. See a richer scenario in Examples.
Accessibility
Section titled “Accessibility”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-labeloraria-labelledby. - No interactive children in summary:
<summary>has an implicitbuttonrole. Nesting links, buttons, or other interactive elements insideSteppedAccordionSummaryis 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-disabledand 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
40pxtall.
SteppedAccordion
Section titled “SteppedAccordion”| Prop | Type | Required | Default |
|---|---|---|---|
className | string | - | - |
onClick | MouseEventHandler<HTMLDivElement> | - | - |
onMouseOver | MouseEventHandler<HTMLDivElement> | - | - |
onMouseOut | MouseEventHandler<HTMLDivElement> | - | - |
style | CSSProperties | - | - |
SteppedAccordionDetails
Section titled “SteppedAccordionDetails”| Prop | Type | Required | Default |
|---|---|---|---|
open | boolean | ✓ | - |
| Whether the details are open. | |||
hidden | boolean | - | - |
id | string | - | - |
title | string | - | - |
dir | string | - | - |
lang | string | - | - |
slot | string | - | - |
translate | "yes" | "no" | - | - |
style | CSSProperties | - | - |
onClick | MouseEventHandler<HTMLDetailsElement> | - | - |
onPointerEnter | PointerEventHandler<HTMLDetailsElement> | - | - |
onPointerMove | PointerEventHandler<HTMLDetailsElement> | - | - |
onPointerDown | PointerEventHandler<HTMLDetailsElement> | - | - |
onPointerUp | PointerEventHandler<HTMLDetailsElement> | - | - |
onPointerLeave | PointerEventHandler<HTMLDetailsElement> | - | - |
children | ReactNode | ✓ | - |
| The content of the accordion. The first child should be the `AccordionSummary` component. | |||
className | string | - | - |
| 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. | |||
SteppedAccordionSummary
Section titled “SteppedAccordionSummary”| Prop | Type | Required | Default |
|---|---|---|---|
hidden | boolean | - | - |
id | string | - | - |
title | string | - | - |
dir | string | - | - |
lang | string | - | - |
slot | string | - | - |
translate | "yes" | "no" | - | - |
style | CSSProperties | - | - |
onFocus | FocusEventHandler<HTMLElement> | - | - |
onBlur | FocusEventHandler<HTMLElement> | - | - |
onClick | MouseEventHandler<HTMLElement> | - | - |
onKeyDown | KeyboardEventHandler<HTMLElement> | - | - |
onKeyUp | KeyboardEventHandler<HTMLElement> | - | - |
onPointerEnter | PointerEventHandler<HTMLElement> | - | - |
onPointerMove | PointerEventHandler<HTMLElement> | - | - |
onPointerDown | PointerEventHandler<HTMLElement> | - | - |
onPointerUp | PointerEventHandler<HTMLElement> | - | - |
onPointerLeave | PointerEventHandler<HTMLElement> | - | - |
children | ReactNode | ✓ | - |
| The label of the summary. Should not contain interactive elements. | |||
icon | ReactNode | - | - |
| 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. | |||
className | string | - | - |
| Custom class name, merged with existing classes. | |||