Accordion
Stacked sections that expand and collapse without leaving the page.
Left out of Accessible first Optional help here is a single section a person can open. Accessible first keeps one clear way to do each thing, so a stack of sections adds a second way. Use instead: Collapsible
See it live
npm run storybookWhen to use it
- Use it when: Optional detail, questions and answers, grouped content people may skip.
- Not when: A decision that blocks the page, a side panel, or a hint on hover.
Instead:
- Tabs: Peer views of the same thing, one at a time.
- Collapsible: A single section, not a stack.
- Dialog: A blocking decision.
Words
- Use common words. Explain any term you must use.
- One idea per sentence. Put the action first.
- Never blame the person.
- Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.
The labels components use, from the voice tokens:
content.action.commit: Continuecontent.action.cancel: Go backcontent.action.destroy: Deletecontent.action.retry: Try againcontent.action.empty-action: Start a new application
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Enter or Space opens and closes the focused section. | undefined |
Test before you ship:
- Each header is a button inside a heading and says whether it is open. undefined
Use it in code
npx open-ds add accordion
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Accordion reads 16 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Accordion's tokens to change Accordion alone.
Accessible first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Accordion | ||
| Divider Changes with theme | component.accordion.dividercolor.border.defaultvar(--accordion-divider) | Lightgray.light.200:#D6D6D6Darkgray.dark.100:#222222 |
| Trigger | ||
| Text Changes with theme | component.accordion.trigger.labelcolor.text.primaryvar(--accordion-trigger-label) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Text size | component.accordion.trigger.font-sizetype.body.font-sizevar(--accordion-trigger-font-size) | font.size.19:1.1875rem |
| Weight | component.accordion.trigger.font-weighttype.label.font-weightvar(--accordion-trigger-font-weight) | font.weight.700:700 |
| Padding, top and bottom | component.accordion.trigger.padding-yspace.inset.containervar(--accordion-trigger-padding-y) | space.24:1.5rem |
| Gap | component.accordion.trigger.gapspace.gap.groupvar(--accordion-trigger-gap) | space.32:2rem |
| Corner | component.accordion.trigger.radiusradius.controlvar(--accordion-trigger-radius) | radius.6:0.375rem |
| Focus ring offset focus Changes with theme on focus | component.accordion.trigger.focus-ring-offset-focuscolor.surface.canvasvar(--accordion-trigger-focus-ring-offset-focus) | Lightgray.light.50:#F7F7F7Darkgray.dark.0:#0A0A0A |
| Focus ring | ||
| Color Changes with theme on focus | component.accordion.focus-ringcolor.border.focusvar(--accordion-focus-ring) | Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8 |
| Width on focus | component.accordion.focus-ring.widthborder-width.focusvar(--accordion-focus-ring-width) | border-width.3:3px |
| Disabled | ||
| Opacity when disabled | component.accordion.disabled.opacityopacity.disabledvar(--accordion-disabled-opacity) | opacity.50:0.5 |
| Icon | ||
| Color Changes with theme | component.accordion.iconcolor.text.mutedvar(--accordion-icon) | Lightgray.light.500:#595959Darkgray.dark.500:#949494 |
| Size | component.accordion.icon.sizesize.iconvar(--accordion-icon-size) | size.20:1.25rem |
| Speed | component.accordion.icon.durationmotion.duration.feedbackvar(--accordion-icon-duration) | duration.moderate:200ms |
| Content | ||
| Text size | component.accordion.content.font-sizetype.body.font-sizevar(--accordion-content-font-size) | font.size.19:1.1875rem |
| Padding, bottom | component.accordion.content.padding-bottomspace.inset.containervar(--accordion-content-padding-bottom) | space.24:1.5rem |