Skip to main content

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​

Start Storybook to see it live: npm run storybook

When 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: Continue
  • content.action.cancel: Go back
  • content.action.destroy: Delete
  • content.action.retry: Try again
  • content.action.empty-action: Start a new application

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedEnter 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.

Changes with theme

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.

PartIts token and the semantic it aliasesValue
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 sizecomponent.accordion.trigger.font-sizetype.body.font-sizevar(--accordion-trigger-font-size)font.size.19:1.1875rem
Weightcomponent.accordion.trigger.font-weighttype.label.font-weightvar(--accordion-trigger-font-weight)font.weight.700:700
Padding, top and bottomcomponent.accordion.trigger.padding-yspace.inset.containervar(--accordion-trigger-padding-y)space.24:1.5rem
Gapcomponent.accordion.trigger.gapspace.gap.groupvar(--accordion-trigger-gap)space.32:2rem
Cornercomponent.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
Sizecomponent.accordion.icon.sizesize.iconvar(--accordion-icon-size)size.20:1.25rem
Speedcomponent.accordion.icon.durationmotion.duration.feedbackvar(--accordion-icon-duration)duration.moderate:200ms
Content
Text sizecomponent.accordion.content.font-sizetype.body.font-sizevar(--accordion-content-font-size)font.size.19:1.1875rem
Padding, bottomcomponent.accordion.content.padding-bottomspace.inset.containervar(--accordion-content-padding-bottom)space.24:1.5rem