Skip to the content

Accordion

A list of rows that open and close to reveal their content. Each row is a native <details> / <summary>, so opening, closing, the keyboard and the announced state come from the browser — no JavaScript. The same markup works in server HTML with no client React.
Data Display@apollion-dsi/core/data-display/accordion25.9 kB gzip

When to use

Use when
  • Related topics where the reader needs only some at a time: services, FAQs, settings groups.
  • Collapsing secondary detail keeps a long page short.
  • A static or server-rendered page must stay interactive without client JavaScript.
Avoid when
  • Switching between peer views of one object — use Tabs.
  • Two or three short items, or content every reader must see — show it.
  • The row title needs a link or a button — the whole row is already the control.

Usage

All rows start closed; any number can be open (type="multiple", the default).

Shipping

Orders ship within two business days.

Returns

Returns are free within 30 days.
import { Accordion } from '@apollion-dsi/core/data-display/accordion';

<Accordion
  items={[
    { value: 'shipping', title: 'Shipping', content: <Text>Orders ship within two business days.</Text> },
    { value: 'returns', title: 'Returns', content: <Text>Returns are free within 30 days.</Text> },
  ]}
/>;

defaultValue opens rows in the initial markup (string[] here). It is uncontrolled: changing it later re-applies the open state over the reader's choice. onItemToggle(value, open) reports every open and close the reader makes.

One open at a time

type="single" puts every row in a native <details name> group, so the browser keeps at most one open. name is required and must be unique on the page: two accordions sharing a name behave as one group. defaultValue takes one string.

Coaching

One-to-one
Weekly sessions.

Workshops

Half-day
Teams of up to twelve.
<Accordion type="single" name="services" defaultValue="workshops" indicator="plus" items={services} />

Look

  • variant="divided" (default) is one surface with hairlines between rows; "separated" makes each row a surface.
  • indicator="chevron" (default) rotates; "plus" turns into ×.
  • Surface props (bgColor, borderColor, borderRadius, borderWidth, borderPosition) override one instance.

Set a brand look for every accordion in the theme, never in className:

createTheme({
  component: {
    accordion: {
      surface: { borderRadius: 'sm', borderColor: 'main' },
      title: { fontSize: 'medium', color: 'main' },
      indicator: { color: 'main' },
    },
  },
});

Rows animate open and closed where the browser supports ::details-content, and toggle instantly elsewhere; reduced motion turns the transition off. With a CSS purge tool, keep [open] selectors and the ::details-content / ::marker pseudo-elements.

Accessibility

  • Each title is a real heading inside the <summary>: set headingLevel (default 3) to fit the page outline.
  • Titles and descriptions take phrasing content only — no links or buttons inside the row header.
  • Some screen-reader and browser pairs do not list headings inside a <summary>; the row itself is always announced with its expanded state.

Properties

Beyond the props above, the component accepts the surface props (spacing, background, border) — not repeated here.

See also