Accordion
Stacked sections that expand and collapse without leaving the page.
In Content first
See it live
npm run storybookWhen to use it
In Content first: Questions and answers in guides.
- 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
- Write to one person: "you", not "users".
- Short sentences with room to breathe.
- Explain why before asking for anything.
- Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Not nowcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Browse guides
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.
Content 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) | Lightstone.light.200:#E4DDD0Darkstone.dark.100:#2E2A24 |
| Trigger | ||
| Text Changes with theme | component.accordion.trigger.labelcolor.text.primaryvar(--accordion-trigger-label) | Lightstone.light.900:#1F1B16Darkstone.dark.900:#FFFDF8 |
| Text size | component.accordion.trigger.font-sizetype.body.font-sizevar(--accordion-trigger-font-size) | font.size.18:1.125rem |
| Weight | component.accordion.trigger.font-weighttype.label.font-weightvar(--accordion-trigger-font-weight) | font.weight.600:600 |
| 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.8:0.5rem |
| Focus ring offset focus Changes with theme on focus | component.accordion.trigger.focus-ring-offset-focuscolor.surface.canvasvar(--accordion-trigger-focus-ring-offset-focus) | Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D |
| Focus ring | ||
| Color Changes with theme on focus | component.accordion.focus-ringcolor.border.focusvar(--accordion-focus-ring) | Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4 |
| Width on focus | component.accordion.focus-ring.widthborder-width.focusvar(--accordion-focus-ring-width) | border-width.2:2px |
| Disabled | ||
| Opacity when disabled | component.accordion.disabled.opacityopacity.disabledvar(--accordion-disabled-opacity) | opacity.40:0.4 |
| Icon | ||
| Color Changes with theme | component.accordion.iconcolor.text.mutedvar(--accordion-icon) | Lightstone.light.600:#61594DDarkstone.dark.400:#A39A8B |
| Size | component.accordion.icon.sizesize.iconvar(--accordion-icon-size) | size.16:1rem |
| 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.18:1.125rem |
| Padding, bottom | component.accordion.content.padding-bottomspace.inset.containervar(--accordion-content-padding-bottom) | space.24:1.5rem |