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.
Purpose
A vertical stack of headers that open and fold panels of content: FAQs, settings groups, product details and filter groups. It is not an M3 component, so it comes from @windmorph/react-pro. It is designed to M3's guidelines: the headers are list items, with the list's tokens, type, heights and density, and the panels open on Expressive springs.
One item opens at a time by default, which keeps a long list short; pass multiple to let several stay open, when people compare panels or work through them in any order.
Use Collapse for one region your own control opens, a List with childItems for nested rows, and Tabs for peer views the person switches between.
Behaviour
- One item is open at a time, and it can fold fully;
multiplelets several stay open. The open items areexpandedKeys(controlled) ordefaultExpandedKeys, by each item'sid, andonExpandedChangegets the new set. - An item's
onExpandedChangereports every open or fold a person causes: its header pressed, its content found by find-in-page or a link, or, one at a time, folded because another item opened. It isn't called when your app changesexpandedorexpandedKeys. standarditems are transparent rows with a divider between them.segmenteditems are containers 2px apart, with a segmented list's corners: small at rest, rounder when hovered, and fully round while open, focused or pressed, on the fast spatial spring.- Panels open on the default spatial spring and fold on the effects spring's easing, so a folding panel never bounces. Opening one item as another folds moves both together, so the accordion keeps its height on every frame. The chevron turns over on the fast spatial spring.
- Closed panels stay in the page as
hidden="until-found": the browser's find-in-page and a#fragmentlink open the panel holding the match, and closed answers are in the server's HTML for search engines. Safari before 26.2 can't find text in a closed panel (26.2 finds it but may not scroll to it); its panels still open from their headers as everywhere else. - An item takes a
title(withleadingcontent,supportingTextand anexpandIcon) and its panel content as children; for a header of your own, compose anAccordionHeaderand anAccordionPanelinstead. AnAccordionItemon its own takesexpanded,defaultExpandedandonExpandedChange. densitytakes 4px a step off the headers, as a core list's rows: 56px at 0 and 44px at −3 for one line.
When not to use
For one region your own control opens use Collapse; for nested rows, a List with child items; for peer views, Tabs.
See also
- Collapse: Content that opens and folds on its height, as an accordion when two switch together: reply fields, answers, more filters. Not an M3 component (@windmorph/react-pro).
- List: Rows with headline, overline, supporting text and leading or trailing content (icons, avatars, images, video thumbnails); items can be links, switches, checkboxes or radio buttons, and put in order by drag or a menu.
- Tabs: Primary and secondary tab rows with a sliding indicator, scrollable when they overflow.