Skip to main content

Accordion

Stacked sections that expand and collapse without leaving the page.

In Multi-brand

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Multi-brand: Frequent questions.

  • 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​

  • Shared structure: object, state, next step.
  • Brand tone lives in headlines and marketing copy, not in errors.
  • Errors and confirmations read the same in every brand.
  • Use: Get started, Plan, Order. Avoid: Brand-specific words in errors, Jargon.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Remove
  • content.action.retry: Try again
  • content.action.empty-action: Get started

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

Multi-brand decides what changes when you switch theme. Here a switch changes colors, type and shape, so the marked rows differ between its brands and 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)Aster Lightslate-deep.light.200:#E2E8F0Aster Darkslate-deep.dark.100:#1E293BBirch Lightslate-deep.light.200:#E2E8F0Birch Darkslate-deep.dark.100:#1E293BCoral Lightslate-deep.light.200:#E2E8F0Coral Darkslate-deep.dark.100:#1E293B
Trigger
Text
Changes with theme
component.accordion.trigger.labelcolor.text.primaryvar(--accordion-trigger-label)Aster Lightslate-deep.light.900:#0F172AAster Darkslate-deep.dark.900:#F8FAFCBirch Lightslate-deep.light.900:#0F172ABirch Darkslate-deep.dark.900:#F8FAFCCoral Lightslate-deep.light.900:#0F172ACoral Darkslate-deep.dark.900:#F8FAFC
Text sizecomponent.accordion.trigger.font-sizetype.body.font-sizevar(--accordion-trigger-font-size)font.size.16:1rem
Weightcomponent.accordion.trigger.font-weighttype.label.font-weightvar(--accordion-trigger-font-weight)font.weight.600:600
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.24:1.5rem
Corner
Changes with theme
component.accordion.trigger.radiusradius.controlvar(--accordion-trigger-radius)Aster Lightradius.4:0.25remAster Darkradius.4:0.25remBirch Lightradius.12:0.75remBirch Darkradius.12:0.75remCoral Lightradius.999:9999pxCoral Darkradius.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)Aster Lightslate-deep.light.50:#F8FAFCAster Darkslate-deep.dark.0:#020617Birch Lightslate-deep.light.50:#F8FAFCBirch Darkslate-deep.dark.0:#020617Coral Lightslate-deep.light.50:#F8FAFCCoral Darkslate-deep.dark.0:#020617
Focus ring
Color
Changes with theme
on focus
component.accordion.focus-ringcolor.border.focusvar(--accordion-focus-ring)Aster Lightteal.light.600:#0F766EAster Darkteal.dark.600:#7FCFC6Birch Lightpurple.light.600:#6D28D9Birch Darkpurple.dark.600:#B79DF7Coral Lightorange.light.600:#C2410CCoral Darkorange.dark.600:#F7A67F
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)Aster Lightslate-deep.light.600:#4B5A6FAster Darkslate-deep.dark.400:#96A3B5Birch Lightslate-deep.light.600:#4B5A6FBirch Darkslate-deep.dark.400:#96A3B5Coral Lightslate-deep.light.600:#4B5A6FCoral Darkslate-deep.dark.400:#96A3B5
Sizecomponent.accordion.icon.sizesize.iconvar(--accordion-icon-size)size.16:1rem
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.16:1rem
Padding, bottomcomponent.accordion.content.padding-bottomspace.inset.containervar(--accordion-content-padding-bottom)space.24:1.5rem