Accordion
A stack of independent native <details> (the mock's .acc); each opens on its own.
import { Accordion } from '@ergasti/bricks';Examples
Wallet groups
Native <details> rows: the summary is the button, total sits at the far end, and Space and Enter toggle it.
Code
import { Accordion, Money } from '@ergasti/bricks';
function WalletGroups() {
const rows: Array<[string, string, Array<[string, string]>]> = [
['Winter glow launch', '-102760.00', [['Commission on 214 delivered orders', '-27645.00'], ['Gifts sent: 68 of 100', '-61200.00'], ['TRNDR fee', '-13915.00']]],
['Top-ups', '287800.00', [['Bank transfer, ref 88412', '250000.00'], ['Card top-up', '37800.00']]],
];
return (
<Accordion>
{rows.map(([name, total, lines], i) => (
<Accordion.Item key={name} summary={name} total={<Money value={total} />} open={i === 0}>
{lines.map(([what, amount]) => (
<div key={what} style={{ display: 'flex', justifyContent: 'space-between', gap: 12, padding: '10px 0', borderTop: '1px solid var(--line)' }}>
<span>{what}</span>
<Money value={amount} />
</div>
))}
</Accordion.Item>
))}
</Accordion>
);
}Props
Prop
Type
Accordion.Item
Prop
Type
Design guidance
How the BRICKS design system uses Accordion. Written in docs/content/components/Accordion.md; the props above are read from the code, which wins where the two disagree.
A stack of independent native <details> rows, each with a summary line and an optional total; use it to group long lists (ledger entries by challenge) that the reader opens one at a time.
Each item opens on its own (it is not an exclusive accordion). It is the mock's .acc: the soft grey rows of Payments › Wallet › "Where your money went", where each challenge group shows its signed total and expands to its entries. WalletLedger draws the same .kit-acc markup.
Anatomy
- Stack:
.kit-accs, a flex column, 8px gap. - Item:
.kit-acc, a native<details>, radius 16,--softbackground. - Summary:
<summary>row, padding 14px 16px, 12px gap; the native marker is hidden. - Summary text:
.kit-acc-s, takes the remaining width. - Total (optional):
.kit-acc-total, bold,kit-numtabular digits,dir="ltr". - Toggle glyph: CSS
::after, "+" closed, "–" open, in--ink-3. - Panel:
.kit-acc-in, padding 0 16px 12px.
Variants
There are no visual variants. Per item: with or without total; initially open or closed.
States
| State | Trigger |
|---|---|
| Closed | default; glyph "+". |
| Open | user toggles, or open on Accordion.Item; glyph "–". open sets the initial state only (native, uncontrolled after that). |
| Focus-visible | inset ring on the summary (--focus-ring-inset). |
| Long summary | the summary text wraps; the total stays on the line end. |
Usage
<Accordion>
<Accordion.Item summary="Ramadan glow challenge" total="-27,640.00" open>
<RowItems label="Ramadan glow challenge entries" items={entries} />
</Accordion.Item>
<Accordion.Item summary="Commission outside challenges" total="-18,900.00">
<RowItems label="Commission outside challenges entries" items={other} />
</Accordion.Item>
<Accordion.Item summary="Top-ups" total="+61,840.00">
<RowItems label="Top-up entries" items={topUps} />
</Accordion.Item>
</Accordion>// Inside a card, as the wallet's "Where your money went"
<Card title="Where your money went" actions={<Segmented label="View" options={views} value={view} onChange={setView} />}>
<Accordion>{groups.map((g) => (
<Accordion.Item key={g.id} summary={g.name} total={formatSigned(g.total)}>{g.rows}</Accordion.Item>
))}</Accordion>
</Card>Where it appears
- Brand › Payments › Wallet › "Where your money went" (grouped by challenge); shown on the BrandWallet screen through
WalletLedger.
Guidelines
Do
- Keep the summary to one name; put the figure in
total. - Open the first or most relevant group by default.
Don't
- Don't nest accordions.
- Don't hide the only copy of a critical figure inside a closed item.
- Don't use it for navigation or tabs; use
PillTabs.
RTL and Arabic
- Logical properties throughout: the glyph uses
margin-inline-start, the total sits at the inline end. - The total keeps
dir="ltr"so signs and digits do not reorder in Arabic.
Tokens
--soft, --ink-3, --focus-ring-inset.
Accessibility
- Native
<details>/<summary>: keyboard (Enter / Space) and expanded state are built in; no ARIA needed. - The total is inside the summary, so it is read as part of the button's name; keep it short.
- Focus ring is inset so the rounded clipping does not cut it.
Found in the source
- No roles, ARIA attributes or key handling are set in this component's own source; it renders native elements and the components it composes.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
WalletLedger: the full "Where your money went" card built on this markup.RowItems: entry rows inside a panel.PillTabs/Segmented: switch views instead of revealing content.
See also: Card · Money · HeroCard · KeyValue · KpiCard
Source
src/kit/patterns/Accordion.tsx (line 5) on GitHub.