Accordion
Stacked sections that expand and collapse without leaving the page.
In Brand expressive
See it live
npm run storybookWhen to use it
In Brand expressive: Questions and answers people may skip. Not to hide a section's one big idea.
- 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
- Headlines are short and bold. Three to six words.
- Verbs that move: Join, Try, Go.
- Playful in headlines, plain in errors.
- Use: Join, Drop, Go, Love. Avoid: Synergy, Leverage, Kindly.
The labels components use, from the voice tokens:
content.action.commit: Gocontent.action.cancel: Not nowcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Explore the drop
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.
Brand expressive 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) | Lighttaupe.light.200:#F2DCCFDarktaupe.dark.100:#33241F |
| Trigger | ||
| Text Changes with theme | component.accordion.trigger.labelcolor.text.primaryvar(--accordion-trigger-label) | Lighttaupe.light.900:#1F1411Darktaupe.dark.900:#FFF8F3 |
| Text size | component.accordion.trigger.font-sizetype.body.font-sizevar(--accordion-trigger-font-size) | font.size.17:1.0625rem |
| 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.32:2rem |
| Gap | component.accordion.trigger.gapspace.gap.groupvar(--accordion-trigger-gap) | space.40:2.5rem |
| Corner | component.accordion.trigger.radiusradius.controlvar(--accordion-trigger-radius) | radius.999:9999px |
| Focus ring offset focus Changes with theme on focus | component.accordion.trigger.focus-ring-offset-focuscolor.surface.canvasvar(--accordion-trigger-focus-ring-offset-focus) | Lighttaupe.light.50:#FFF8F3Darktaupe.dark.0:#120B09 |
| Focus ring | ||
| Color Changes with theme on focus | component.accordion.focus-ringcolor.border.focusvar(--accordion-focus-ring) | Lightpink.light.600:#D61F7ADarkpink.dark.600:#F59ACA |
| 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.40:0.4 |
| Icon | ||
| Color Changes with theme | component.accordion.iconcolor.text.mutedvar(--accordion-icon) | Lighttaupe.light.600:#6B544ADarktaupe.dark.400:#B5988A |
| Size | component.accordion.icon.sizesize.iconvar(--accordion-icon-size) | size.20:1.25rem |
| Speed | component.accordion.icon.durationmotion.duration.feedbackvar(--accordion-icon-duration) | duration.fast:120ms |
| Content | ||
| Text size | component.accordion.content.font-sizetype.body.font-sizevar(--accordion-content-font-size) | font.size.17:1.0625rem |
| Padding, bottom | component.accordion.content.padding-bottomspace.inset.containervar(--accordion-content-padding-bottom) | space.32:2rem |