Accordion
ProA stack of headers that open and fold panels of content, one at a time or several: FAQs, settings groups, product details and filters. Not an M3 component (@windmorph/react-pro).
import { Accordion, AccordionItem, AccordionHeader, AccordionPanel } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Props
Accordion 13 props
The items:
AccordionItems.standard: transparent rows with a divider between them, like a standard list.segmented: each item a container, 2px apart, with a segmented list's corners; the open item rounds fully.Whether several items may be open at once (as
<select multiple>). Otherwise opening one folds the others.The open items'
ids (controlled).The items open at first (uncontrolled).
Disables every item: headers can't be pressed or focused.
The heading level of every header (
h2–h6), to fit the page's outline. An item or a header can set its own.The density,
0to-3: each step takes 4px off the headers' heights (56 → 44px), as a core list's. Left out, it follows the nearestdata-density(--md-sys-density).The root element. Its other props (
id,className,style, e.g.--wm-accordion-*tokens,aria-*,data-*, handlers) go to it too.
Events
Called with the open items'
ids when an item opens or folds.
Classes for each part, applied to every item.
The root, holding the items.
Each item: its header and its panel. A segmented item is its container.
The heading element (
h2–h6) wrapping each header.Each header: the
<button>that opens and folds its panel.The leading content of a header (an icon, an avatar).
A header's title.
A header's supporting text.
The chevron at the end of a header.
Each panel: the part that opens and folds.
A panel's content, padded, inside the part that opens and folds.
Classes for the root element, merged with the component's own (yours win).
Inline styles for the root element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
AccordionItem 16 props
The panel's content.
The header's title, which names its button (and its panel's region).
The item's key in its accordion's
expandedKeys. Not written to the page. Left out, the item gets a generated one (fine when nothing refers to it).Disables the item: its header can't be pressed or focused (React Aria's default).
Whether it's open (controlled), for an item outside an accordion.
Whether it starts open (uncontrolled), for an item outside an accordion.
The heading level of its header (
h2–h6).How it's drawn when it stands alone; inside an accordion, the accordion's.
The item element.
Leading content before the title: an icon (20px, as a list item's), an avatar or an image.
A line under the title.
Replaces the chevron at the end of the header. It turns over as the panel opens.
Events
Called with the new state whenever a person opens or folds the item: its header pressed, its content found by find-in-page or a
#fragmentlink, or, in a one-at-a-time accordion, folded because another item opened (as a<details name>group firestoggleon the one it closes). Not called when the app changesexpandedor the accordion'sexpandedKeysitself.
Classes for the item; they win over the component's own (
cn()).Classes for each part; they come after the accordion's.
A header's title.
A panel's content, padded, inside the part that opens and folds.
Each item: its header and its panel. A segmented item is its container.
The heading element (
h2–h6) wrapping each header.Each header: the
<button>that opens and folds its panel.The leading content of a header (an icon, an avatar).
A header's supporting text.
The chevron at the end of a header.
Each panel: the part that opens and folds.
Inline styles for the item.
AccordionHeader 9 props
The title, which names the header's button (and its panel's region).
The heading level (
h2–h6).The header's
<button>. The other props (id, for a link to the heading,className,style,aria-*,data-*) go to the heading element, the header's outermost.Leading content before the title: an icon (20px, as a list item's), an avatar or an image.
A line under the title.
Replaces the chevron at the end of the header. It turns over as the panel opens.
Classes for each part; they come after the accordion's and the item's.
A header's title.
The heading element (
h2–h6) wrapping each header.Each header: the
<button>that opens and folds its panel.The leading content of a header (an icon, an avatar).
A header's supporting text.
The chevron at the end of a header.
Classes for the root element, merged with the component's own (yours win).
Inline styles for the root element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
AccordionPanel 5 props
What the panel shows while open.
The panel element (the part that opens and folds). Its other props (
id,className,style, e.g.--wm-collapse-*tokens,aria-*,data-*) go to it too.
Classes for each part; they come after the accordion's and the item's.
Classes for the root element, merged with the component's own (yours win).
Inline styles for the root element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Spec status
Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.
| Item | Status | Details |
|---|---|---|
Standard rows with dividers (variant="standard") | Built | Variant · Faq |
Segmented containers (variant="segmented") | Built | Variant · Segmented, Parts |
| One item open at a time, which can fold fully | Built | Configuration · Faq |
Several open at once, controlled (multiple, expandedKeys) | Built | Configuration · Multiple |
| Leading icons and supporting text | Built | Configuration · Multiple, Dense |
A header from parts (AccordionHeader, AccordionPanel), and a disabled item | Built | Configuration · Parts |
Density, as a core list (density) | Built | Configuration · Dense |
Closed panels found by find-in-page and #fragment links | Built | Use case · Find in page |
| A FAQ, or a long answer with links | Built | Use case · Faq, Long panel |
Standard rows with dividers (
Builtvariant="standard")Variant · Faq
One item open at a time, which can fold fully
BuiltConfiguration · Faq
Several open at once, controlled (
Builtmultiple,expandedKeys)Configuration · Multiple
A header from parts (
BuiltAccordionHeader,AccordionPanel), and a disabled itemConfiguration · Parts
Density, as a core list (
Builtdensity)Configuration · Dense
Closed panels found by find-in-page and
Built#fragmentlinksUse case · Find in page
A FAQ, or a long answer with links
BuiltUse case · Faq, Long panel
Theming & tokens
Set the tokens below on the accordion or any ancestor. The headers are list items, so they also take the core list's --md-comp-list-list-item-* tokens (heights, colours, type), and the panels take Collapse's --wm-collapse-* timing. Style the parts with classNames (root, item, heading, header, leading, title, supportingText, chevron, panel, content), on the accordion for every item or on one item.
| Variable | Default | Paints |
|---|---|---|
--wm-accordion-segmented-gap | 2px | The space between segmented items (a segmented list’s 2px). |
--wm-accordion-divider-color | var(--md-sys-color-outline-variant) | The line between standard items. |
--wm-accordion-corner | var(--md-sys-shape-corner-extra-small) | A segmented item’s corners at rest (a list item’s). |
--wm-accordion-outer-corner | var(--md-sys-shape-corner-large) | The outer corners of the first and last segmented items, and the corners that meet an open item. |
--wm-accordion-hover-corner | var(--md-sys-shape-corner-medium) | A segmented item’s corners while its header is hovered. |
--wm-accordion-open-corner | var(--md-sys-shape-corner-large) | A segmented item’s corners while it is open, or its header is focused or pressed (a list item’s active shape). |
--wm-accordion-morph-duration | var(--md-sys-motion-spring-spatial-fast-duration) | How long the corners morph and the chevron turns (the fast spatial spring; at once under reduced motion). |
--wm-accordion-morph-easing | var(--md-sys-motion-spring-spatial-fast-easing) | Their easing. |
--wm-accordion-chevron-color | var(--md-sys-color-on-surface-variant) | The chevron at the end of each header. |
--wm-accordion-chevron-size | 24px | The chevron’s size. |
--wm-accordion-panel-padding-inline | 16px | The space on each side of a panel’s content, lined up with the header’s. |
--wm-accordion-panel-padding-top | 0px | The space above a panel’s content. |
--wm-accordion-panel-padding-bottom | 16px | The space below a panel’s content. |
--wm-accordion-panel-text-color | var(--md-sys-color-on-surface) | A panel’s text. |