component
Accordion
Several things that open one by one, like questions and answers: Disclosures in a column, a line between each.
Try it
Every variant
What counts as an expense?
The short answer, in a sentence or two.
When is tax due?
The short answer, in a sentence or two.
Can I export my data?
The short answer, in a sentence or two.
Defaultimport { Accordion } from 'rost/components/accordion/Accordion'
<Accordion items={[
{ summary: 'When is tax due?', content: <Text>By 25 May for the year before.</Text> },
]} /> src/components/accordion/Accordion.tsx
import type { HTMLAttributes, ReactNode } from 'react'
import { Disclosure } from '../disclosure/Disclosure'
import './accordion.css'
export interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
/** Each a summary and what opens. */
readonly items: readonly { readonly summary: ReactNode; readonly content: ReactNode; readonly open?: boolean }[]
}
const b = 'rost-accordion'
/** Disclosures in a column, a line between each. Built from contracts/accordion.contract.yaml. */
export function Accordion({ items, className, ...rest }: AccordionProps) {
return (
<div className={[b, className].filter(Boolean).join(' ')} {...rest}>
{items.map((item, i) => <Disclosure key={i} className={`${b}__item`} summary={item.summary} open={item.open}>{item.content}</Disclosure>)}
</div>
)
}
The source for everything on this page: contracts/accordion.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: accordion
name: Accordion
kind: component
status: review
summary: "Several things that open one by one, like questions and answers: Disclosures in a column, a line between each."
category: surfaces
related: [ disclosure, description-list ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "745:29"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=745-29
extractedAt: "2026-11-16"
extractedBy: hand
frozenAt: "2026-11-16"
props:
items: { type: slot, required: true, notes: "Each a summary and what opens." }
elements:
root:
notes: "A `<div>` holding the items in a column."
styles:
display: { value: flex, assert: false }
flex-direction: { value: column, assert: false }
item:
notes: "A Disclosure, as it is, with 12px above and below and a 1px line under it."
styles:
padding-top: { token: spacing/gap/small-medium, value: 12px }
padding-bottom: { token: spacing/gap/small-medium, value: 12px }
border-bottom-style: { value: solid, assert: false }
border-bottom-width: { token: spacing/outline/small, value: 1px }
border-bottom-color: { token: accordion/divider, value: "#3a3a3a" }
guidance:
status: proposed
use:
- title: Questions and answers
text: "A few questions where most people need one answer: what counts as a business expense, when tax is due."
avoid:
- title: Things everyone needs
text: "If most people open every item, show them open."
- title: One thing to hide
text: "A single detail out of the way is one **Disclosure**."
behaviour: "Each item opens on its own; opening one doesn't close the others. It's Disclosures in a column with lines between them."
accessibility:
element: "A `<div>` of `<details>`, so each summary is a button the browser knows opens."
keyboard: "Tab moves between summaries; Enter or Space opens and closes."
colour: "The lines are decoration."
Install
npx github:Runceanu/rost add accordion It lands in src/rost/accordion/, with what it needs and its contract. Install has the rest.
When to use
Questions and answers
A few questions where most people need one answer: what counts as a business expense, when tax is due.
When not to use
Things everyone needs
If most people open every item, show them open.
One thing to hide
A single detail out of the way is one Disclosure.
Behaviour
Each item opens on its own; opening one doesn't close the others. It's Disclosures in a column with lines between them.
Accessibility
- Element
A
<div>of<details>, so each summary is a button the browser knows opens. - Keyboard
Tab moves between summaries; Enter or Space opens and closes.
- Colour
The lines are decoration.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
items | slot | | |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
displayflex · flex-directioncolumn
item
-
padding-top12pxspacing/gap/small-medium -
padding-bottom12pxspacing/gap/small-medium -
border-bottom-width1pxspacing/outline/small -
border-bottom-color#3a3a3aaccordion/divider
border-bottom-stylesolid