Skip to content

Commit d8ad0c7

Browse files
authored
docs(design-system-docs): add Accordion component documentation (#4957)
* docs(design-system-docs): add Accordion component documentation Adds the Accordion usage guide to Docusaurus and registers it in the Surfaces sidebar. Covers when to use, structure, independent vs exclusive grouping, controlled/uncontrolled modes, density, native details/summary accessibility, and Figma usage. Refs #4451 * docs(design-system-docs): address Accordion doc review - Replace localhost:9000 Storybook URLs with the deployed host - Restore Autocomplete entry in the Inputs sidebar (accidentally dropped while adding Accordion under Surfaces) - Replace the duplicate Link redirect in the Don't list with a hint about avoiding deeply nested headings inside panels
1 parent b69a15b commit d8ad0c7

2 files changed

Lines changed: 109 additions & 5 deletions

File tree

apps/design-system-docs/docs/components/surfaces/accordion.md

Lines changed: 108 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,135 @@
22
title: Accordion
33
sidebar_position: 1
44
---
5+
56
# Accordion
67

8+
Accordion lets readers reveal and collapse sections of content on demand. It helps manage information density on long pages while keeping the layout scannable, so people can focus on what matters to them without losing the rest of the structure.
9+
10+
<iframe
11+
class="sb-iframe"
12+
src="https://storybook.eds.equinor.com/iframe.html?globals=&args=&id=eds-2-0-beta-surface-accordion--introduction"
13+
width="100%"
14+
height="258"
15+
frameborder="1"
16+
></iframe>
17+
18+
[View in Storybook](https://storybook.eds.equinor.com/?path=/story/eds-2-0-beta-surface-accordion--introduction)
19+
720
## When to Use
821

22+
Use an accordion when a page would otherwise overwhelm readers with long-form content that not everyone needs at once. It works well for grouped supporting detail – FAQs, settings panels, reference material, documentation sections – where the headings give readers a clear map and the panels hold optional depth.
23+
24+
**Avoid Accordion for:**
25+
26+
- Critical information the reader must see – keep it visible in the main flow instead
27+
- Short content that fits without scrolling – the extra click costs more than it saves
28+
- Navigating between pages – use **Link** instead
29+
- Sequential, step-by-step flows – reach for a dedicated stepper pattern
30+
31+
## Structure
32+
33+
Accordion is a compound component built from a small set of parts that compose together:
934

35+
- **Accordion**: The root wrapper that groups items and controls how they behave together
36+
- **Accordion.Item**: A single collapsible section that holds a header and a panel
37+
- **Accordion.Header**: The clickable summary row with a chevron and a title
38+
- **Accordion.Panel**: The revealed content area shown when the item is open
39+
40+
All Accordion items support:
41+
42+
- **Independent open state** by default – any combination of items can be open at once
43+
- **Exclusive grouping** on the root – opening one item closes the others
44+
- **Controlled and uncontrolled modes** at the item level – let consumers manage open state externally or let the component handle it
45+
- **Density** through the ancestor `data-density` attribute, keeping spacing in step with sibling components
1046

1147
## Guidelines
1248

49+
### Independent and Exclusive
50+
51+
By default, accordion items open and close independently of one another. This is the right behaviour when sections cover unrelated topics and a reader might reasonably want to compare or hold two open at the same time.
52+
53+
Switch to an exclusive group when the content is mutually exclusive, when keeping multiple panels open would confuse the layout, or when the surrounding container is short on vertical space.
54+
55+
<iframe
56+
class="sb-iframe"
57+
src="https://storybook.eds.equinor.com/iframe.html?globals=&args=&id=eds-2-0-beta-surface-accordion--exclusive"
58+
width="100%"
59+
height="198"
60+
frameborder="1"
61+
></iframe>
62+
63+
[View in Storybook](https://storybook.eds.equinor.com/?path=/story/eds-2-0-beta-surface-accordion--exclusive)
64+
65+
### Controlled and Uncontrolled
66+
67+
Accordion items work uncontrolled out of the box – the component remembers its own open state and you only need to set the initial value. Reach for a controlled item when the open state is part of broader UI logic: syncing with a URL parameter, restoring layout from saved preferences, or co-ordinating with another panel on the page.
68+
69+
<iframe
70+
class="sb-iframe"
71+
src="https://storybook.eds.equinor.com/iframe.html?globals=&args=&id=eds-2-0-beta-surface-accordion--controlled"
72+
width="100%"
73+
height="169"
74+
frameborder="1"
75+
></iframe>
76+
77+
[View in Storybook](https://storybook.eds.equinor.com/?path=/story/eds-2-0-beta-surface-accordion--controlled)
78+
79+
### Density
80+
81+
Accordion follows the active density on its ancestor, so spacing and sizing stay coordinated with the rest of the layout. Use the spacious default in standalone or content-led views, and switch to comfortable density inside dense surfaces like tools, settings panes, or side panels.
82+
83+
<iframe
84+
class="sb-iframe"
85+
src="https://storybook.eds.equinor.com/iframe.html?globals=&args=&id=eds-2-0-beta-surface-accordion--density"
86+
width="100%"
87+
height="444"
88+
frameborder="1"
89+
></iframe>
90+
91+
[View in Storybook](https://storybook.eds.equinor.com/?path=/story/eds-2-0-beta-surface-accordion--density)
1392

1493
## Accessibility
1594

95+
Accordion is built on the native `<details>` and `<summary>` elements, so disclosure semantics, keyboard support, and screen reader announcements come from the browser without bespoke ARIA wiring.
96+
97+
**Keyboard support:**
98+
99+
- **Tab**: Move focus to and from the accordion header
100+
- **Enter / Space**: Toggle the focused section open or closed
16101

17102
## Figma
18103

104+
### Components
105+
106+
- **Accordion [EDS]**: A single accordion row with the chevron, title, optional content panel, and full state coverage
107+
108+
### Using the Accordion in Figma
109+
110+
1. In the **Assets Panel**, search for **Accordion** and drag the **Accordion [EDS]** component into your frame
111+
2. Stack multiple instances vertically to build a group – the top line on each row handles the shared divider
112+
3. Use the **Open** property to toggle a row between collapsed and expanded
113+
4. Use the **State** property to show **Default**, **Hover**, or **Focus** while documenting interactions
114+
5. Set the **Title** and **Content** text properties on each instance to match your real content
19115

116+
The component reads from the active theme mode on the containing frame, so colours, typography, and spacing follow the rest of your composition without manual overrides.
20117

21-
### Do's and don'ts
118+
## Do's and Don'ts
22119

23120
:::info **Do**
24121

25-
-
122+
- Write headers that clearly describe what is inside, so readers can decide whether to open a section
123+
- Reach for an exclusive group when only one panel should be visible at a time
124+
- Use accordions to support a primary layout, not to replace it
125+
- Keep panel content focused – one topic per item makes the structure scannable
126+
26127
:::
27128

28129
:::danger **Don't**
29130

30-
-
31-
:::
131+
- Hide content people are likely to need on every visit – keep that visible in the main flow
132+
- Nest accordions inside accordions – the layering quickly becomes hard to follow
133+
- Stack a single accordion item on its own – a plain disclosure or section is clearer
134+
- Bury deeply nested headings inside a panel – flatten the content or split it across items
32135

136+
:::

apps/design-system-docs/sidebars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const sidebars: SidebarsConfig = {
9494
{
9595
type: 'category',
9696
label: 'Surfaces',
97-
items: ['components/surfaces/divider'],
97+
items: ['components/surfaces/accordion', 'components/surfaces/divider'],
9898
},
9999
],
100100
//Foundation Section

0 commit comments

Comments
 (0)