Accordion
Rows that show and hide their content: FAQs and static disclosures as native details and summary, and controlled disclosures such as filter groups.
When to use
- Questions and answers, or static sections people open one by one: a FAQ, "How it works" steps on a help page, a booth's details (D-CSN-31).
- Groups of controls people open and close: filter groups ("Work type", "Workplace"), navigation groups in a drawer (compact rows, controlled by script).
- Several rows may be open at once.
When not to use
| Situation | Use instead |
|---|---|
| Content everyone needs to read | Plain sections with headings; never hide what the task needs |
| Switching between peer views of the same place | Tabs |
| A choice that changes a mode | Segmented button |
| A menu of actions | Menu |
| The FAQ section of a landing page | FAQ: this accordion under an h2, up to six questions |
| A one-field edit | A list row that opens a dialog |
Anatomy
- Accordion
.oa-accordion: a column of items, a 1pxoutline-varianthairline above the first and below each (none in--compact). - Item
.oa-accordion__item: a<details>, or adivfor a controlled disclosure. - Summary row
.oa-accordion__summary: the<summary>, or a<button aria-expanded aria-controls>; the label, then the chevron. - Chevron
.oa-accordion__icon:expand_more, 24px, at the inline end, turning 180° when open. - Panel
.oa-accordion__panel: the answer (body-mdon a 24px line,on-surface-variant, at most 640px), or the group's controls.
Variants
| Variant | Class | Use for | Key tokens |
|---|---|---|---|
| Default (static) | oa-accordion with <details> |
FAQs, help, settings sections | --text-title-sm, 64px rows, hairlines --color-outline-variant |
| Default (controlled) | oa-accordion with <button aria-expanded> |
A disclosure that script controls (remembered state, a URL) | as above |
| Compact | oa-accordion oa-accordion--compact |
Filter groups, navigation groups | --text-label-md, 48px rows, --radius-8px, no hairlines |
Use native <details> and <summary> for FAQs and static disclosures: they work without script. Use a button with aria-expanded and aria-controls for disclosures that script controls (filters, navigation groups) (canonical §10.25).
Sizes
| Size | Height | Padding | Type style | Icon size |
|---|---|---|---|---|
| Default row | at least 64px | block 20px; inline 16px (--space-row-inset) |
label title-sm 16/24 600 |
chevron 24px (icon-lg) |
| Default panel | its content's | inline-start 16px, inline-end 48px, bottom 24px; at most 640px wide | body-md 14px on a 24px line |
— |
| Compact row | 48px | inline 8px; corners 8px | label label-md 14/20 600 |
chevron 24px |
| Compact panel | its content's | 8px above its controls | the controls' own | — |
The rows carry 16px of inline padding (8px compact) so the inset focus ring never covers the label; the panel starts on the label's line.
Tokens
| Part | Property | Token |
|---|---|---|
| Item | hairlines | 1px --color-outline-variant above the first, below each |
| Summary | least height, padding | --space-16 (64px), --space-5 block, --space-row-inset inline |
| Summary | type, color | --text-title-sm, --color-on-surface |
| Summary | hover / pressed layer | currentColor at --opacity-state-hover / --opacity-state-pressed |
| Summary | focus | ring offset --size-focus-inset (−4px) |
| Summary | edge | 1px transparent (forced colors) |
| Chevron | color, size, turn | --color-on-surface-variant, --size-icon-lg, transform over --duration-short-4 with --ease-standard |
| Panel | type, color | --text-body-md on --text-body-lg--line-height (24px), --color-on-surface-variant |
| Panel | padding | --space-row-inset start, --space-12 end, --space-6 bottom |
| Compact summary | height, padding, corner, type, color | --size-touch-target, --space-2, --radius-8px, --text-label-md, --color-on-surface-variant |
| Compact panel | top padding | --space-2 |
States
| State | What changes |
|---|---|
| Closed | The panel is hidden (native details, or hidden on a controlled panel); the chevron points down. |
| Open | The panel shows; the chevron turns 180° over duration-short-4 ease-standard (instantly under reduced motion). The panel's height never animates. |
Hover ((hover: hover)) |
8% layer of the label color on the summary row, faded over duration-short-3. |
| Focus-visible | The family ring drawn inset (−4px) on the summary row. |
| Pressed | 12% layer, at once. |
| Disabled | Not used: remove a group that cannot open. |
Behavior
- Several open. Opening one row never closes another (D-CSN-31).
- No height animation. The panel appears in place; only the chevron turns (canonical §7.3).
- Controlled disclosures. The button toggles
aria-expandedand the panel'shiddenattribute together; the panel is arole="group"named by its button (aria-labelledby). A filter group's controls apply at once. - Deep links and print (canonical is silent; a recommendation): a static disclosure may open by script when the page's anchor points inside it, and a help page may open its
detailsbefore printing.
Accessibility
- Elements.
<details>/<summary>: the browser gives the summary its role, its expanded state, and Enter or Space; controlled:<button type="button" aria-expanded aria-controls>. - Headings. A FAQ section has an
h2; the questions are not headings, and a summary never contains a heading element (D-CSN-31). - Names. The summary's text is the name ("How do I join an event?"); the chevron is
aria-hidden. - Keyboard. Tab moves between summary rows; Enter or Space toggles; focus stays on the summary.
- Targets. Default rows at least 64px tall and full width; compact rows 48px.
- Contrast. The label
on-surfaceand the answeron-surface-variantreach 4.5:1 or more on every surface; the chevronon-surface-variant7.2:1 or more. - Forced colors. The summary keeps a 1px edge; hairlines stay; the marker is the drawn chevron, so it stays too.
- Reduced motion. The chevron turns instantly.
RTL and languages
- The chevron sits at the inline end (the left in Arabic) and is not mirrored:
expand_morepoints down in both directions (canonical §8.3). - Logical padding: the panel's 48px clearance stays on the chevron's side.
- Arabic labels and answers take the Arabic line heights from the tokens; the answer keeps its 24px line rhythm.
- French questions run longer: they wrap; never truncate a summary.
Content
- Questions: in the person's words, sentence case, ending with a question mark: "How do I join an event?", "Can I collect points without a phone?", "Does the demo change a real event?" (Global Games); "What is Tamakkan?", "Will my results choose a career for me?" (Tamakkan).
- Answers: a direct answer first ("Yes.", "No."), and two sentences at most (canonical §12.1); links say where they go.
- Filter groups: the facet as a noun, no full stop: "Work type", "Workplace", "Experience", "Date posted"; options with their counts ("Full-time 12").
- Static disclosures: the section's title ("Register or use your invitation") and its text ("Guests can register here. If the ID office invited you, use the one-time link in your email.") (R-80).
- Arabic (Global ID's "How it works" copy, R-80): "سجّل أو استخدم دعوتك" (native review) · "يمكن للضيوف التسجيل هنا. إذا دعاك مكتب الهوية، فاستخدم الرابط المرسل إلى بريدك الإلكتروني والذي يُستخدم مرة واحدة." (native review); Jobs filter group "نوع العمل" with "دوام كامل" and "دوام جزئي". Write the tanween on the letter before the alif, "رابطًا" (canonical §12.6), where Global ID's link messages still write "رابطاً", such as "اطلب رابطاً جديداً".
- Spelling is US English: "organizer", "enroll" (Games' "organiser", "enrol" change, GG-2.20).
Do and don't
| Do | Don't |
|---|---|
Use details and summary for FAQs. |
Build a FAQ with clickable divs. |
Turn the expand_more chevron 180°. |
Use a plus that turns 45° (Games, Tamakkan today) or a bare bold label with no affordance. |
| Let several rows stay open. | Close the other rows when one opens. |
| Keep the answer in place. | Animate the panel's height. |
Put an h2 above the FAQ. |
Make each question a heading. |
Code
HTML (reference CSS)
FAQ and static disclosures:
<div class="oa-accordion">
<details class="oa-accordion__item">
<summary class="oa-accordion__summary">How do I join an event?<span class="oa-icon oa-accordion__icon" aria-hidden="true" translate="no">expand_more</span></summary>
<div class="oa-accordion__panel">
<p>Sign in using an access method connected to your account. Your organizer needs to enroll you in the event before it appears in your events list.</p>
</div>
</details>
<details class="oa-accordion__item" open>
<summary class="oa-accordion__summary">Can I collect points without a phone?<span class="oa-icon oa-accordion__icon" aria-hidden="true" translate="no">expand_more</span></summary>
<div class="oa-accordion__panel">
<p>Yes. Booth staff scan your printed Global ID badge to record a visit.</p>
</div>
</details>
<details class="oa-accordion__item">
<summary class="oa-accordion__summary">Does the demo change a real event?<span class="oa-icon oa-accordion__icon" aria-hidden="true" translate="no">expand_more</span></summary>
<div class="oa-accordion__panel">
<p>No. The browser demo uses fictional people and sample activity.</p>
</div>
</details>
</div>Compact, controlled (filter groups). The rows inside are checkbox rows:
<div class="oa-accordion oa-accordion--compact">
<div class="oa-accordion__item">
<button class="oa-accordion__summary" type="button" id="ct-filter-work-type-btn" aria-expanded="true" aria-controls="ct-filter-work-type">Work type<span class="oa-icon oa-accordion__icon" aria-hidden="true" translate="no">expand_more</span></button>
<div class="oa-accordion__panel" id="ct-filter-work-type" role="group" aria-labelledby="ct-filter-work-type-btn">
<label class="oa-check"><input class="oa-check__input" name="ct-work-type" type="checkbox" value="full-time" checked><span class="oa-check__label">Full-time</span><span class="oa-check__count">12<span class="oa-visually-hidden"> jobs</span></span></label>
<label class="oa-check"><input class="oa-check__input" name="ct-work-type" type="checkbox" value="part-time"><span class="oa-check__label">Part-time</span><span class="oa-check__count">1<span class="oa-visually-hidden"> job</span></span></label>
<label class="oa-check"><input class="oa-check__input" name="ct-work-type" type="checkbox" value="contract"><span class="oa-check__label">Contract</span><span class="oa-check__count">1<span class="oa-visually-hidden"> job</span></span></label>
<label class="oa-check"><input class="oa-check__input" name="ct-work-type" type="checkbox" value="volunteer"><span class="oa-check__label">Volunteer</span><span class="oa-check__count">1<span class="oa-visually-hidden"> job</span></span></label>
</div>
</div>
<div class="oa-accordion__item">
<button class="oa-accordion__summary" type="button" id="ct-filter-workplace-btn" aria-expanded="false" aria-controls="ct-filter-workplace">Workplace<span class="oa-icon oa-accordion__icon" aria-hidden="true" translate="no">expand_more</span></button>
<div class="oa-accordion__panel" id="ct-filter-workplace" role="group" aria-labelledby="ct-filter-workplace-btn" hidden>
<label class="oa-check"><input class="oa-check__input" name="ct-workplace" type="checkbox" value="on-site"><span class="oa-check__label">On-site</span><span class="oa-check__count">8<span class="oa-visually-hidden"> jobs</span></span></label>
<label class="oa-check"><input class="oa-check__input" name="ct-workplace" type="checkbox" value="hybrid"><span class="oa-check__label">Hybrid</span><span class="oa-check__count">3<span class="oa-visually-hidden"> jobs</span></span></label>
<label class="oa-check"><input class="oa-check__input" name="ct-workplace" type="checkbox" value="remote"><span class="oa-check__label">Remote</span><span class="oa-check__count">4<span class="oa-visually-hidden"> jobs</span></span></label>
</div>
</div>
</div>Arabic (Global ID's first two steps, native review):
<div class="oa-accordion">
<details class="oa-accordion__item" open>
<summary class="oa-accordion__summary">سجّل أو استخدم دعوتك<span class="oa-icon oa-accordion__icon" aria-hidden="true" translate="no">expand_more</span></summary>
<div class="oa-accordion__panel">
<p>يمكن للضيوف التسجيل هنا. إذا دعاك مكتب الهوية، فاستخدم الرابط المرسل إلى بريدك الإلكتروني والذي يُستخدم مرة واحدة.</p>
</div>
</details>
<details class="oa-accordion__item">
<summary class="oa-accordion__summary">أنشئ كلمة المرور<span class="oa-icon oa-accordion__icon" aria-hidden="true" translate="no">expand_more</span></summary>
<div class="oa-accordion__panel">
<p>اختر كلمة مرور وأكّدها. ثم أضف مفتاح مرور الآن أو خلال سبعة أيام.</p>
</div>
</details>
</div>
<div class="oa-accordion oa-accordion--compact">
<div class="oa-accordion__item">
<button class="oa-accordion__summary" type="button" id="ct-filter-ar-btn" aria-expanded="true" aria-controls="ct-filter-ar">نوع العمل<span class="oa-icon oa-accordion__icon" aria-hidden="true" translate="no">expand_more</span></button>
<div class="oa-accordion__panel" id="ct-filter-ar" role="group" aria-labelledby="ct-filter-ar-btn">
<label class="oa-check"><input class="oa-check__input" name="ct-work-type-ar" type="checkbox" value="full-time"><span class="oa-check__label">دوام كامل</span><span class="oa-check__count">12</span></label>
<label class="oa-check"><input class="oa-check__input" name="ct-work-type-ar" type="checkbox" value="part-time"><span class="oa-check__label">دوام جزئي</span><span class="oa-check__count">1</span></label>
</div>
</div>
</div>A controlled disclosure toggles two attributes together:
button.addEventListener('click', () => {
const open = button.getAttribute('aria-expanded') === 'true';
button.setAttribute('aria-expanded', String(!open));
document.getElementById(button.getAttribute('aria-controls')).hidden = open;
});Tailwind CSS v4
<div>
<details class="border-b border-outline-variant first:border-t open:[&>summary>span]:rotate-180">
<summary class="relative isolate flex min-h-16 cursor-pointer list-none items-center justify-between gap-4 border border-transparent px-row-inset py-5 text-title-sm text-on-surface before:absolute before:-inset-px before:-z-1 before:bg-current before:opacity-0 before:transition-opacity before:duration-short-3 before:ease-standard hover:before:opacity-(--opacity-state-hover) active:before:opacity-(--opacity-state-pressed) focus-visible:-outline-offset-4 [&::-webkit-details-marker]:hidden">
How do I join an event?
<span aria-hidden="true" class="text-on-surface-variant transition-transform duration-short-4 ease-standard"><!-- expand_more 24px --></span>
</summary>
<div class="max-w-160 ps-row-inset pe-12 pb-6 text-body-md/6 text-on-surface-variant">
<p>Sign in using an access method connected to your account. …</p>
</div>
</details>
</div>
<!-- Compact summary (a button): min-h-12 rounded-8px px-2 py-0 text-label-md text-on-surface-variant, no hairlines; the chevron turns with aria-expanded:[&>span]:rotate-180. -->text-body-md/6 is the one place the answer's 24px line height is written in Tailwind; never add leading-* elsewhere.
React
| Prop | Type | Default | Description |
|---|---|---|---|
Accordion.density |
"default" | "compact" |
"default" |
Compact rows for filters and navigation groups. |
AccordionItem.summary |
ReactNode |
— | Required: the question or the group's name. |
AccordionItem.defaultOpen |
boolean |
false |
Static items (details). |
AccordionItem.open |
boolean |
— | Controlled items render a button with aria-expanded. |
AccordionItem.onOpenChange |
(open: boolean) => void |
— | Controlled items. |
AccordionItem.children |
ReactNode |
— | The answer or the controls. |
<Faq title={t('faq.title')}>
{questions.map((q) => (
<AccordionItem key={q.id} summary={q.question}>{q.answer}</AccordionItem>
))}
</Faq>shadcn/ui: Accordion type="multiple" (or native details), 64px / 48px rows, expand_more 24px, no height animation: remove the animate-accordion-* classes (D-CSN-31, canonical §10.25).