Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Data display

Accordion

A stack of headings that each show or hide their own panel of content.

Selector: mui-accordion

Import
import { AccordionGroup, AccordionItem } from '@mushilu-san/ui/data-display';
PreviewCode

Loading example…

Overview

Accordion is a group of items. Each mui-accordion-item has a heading button that toggles its panel, with aria-expanded and aria-controls linking the two.

By default one panel is open at a time. Set multiple on the group to let several stay open.

When to use

  • FAQs and long settings pages where users look for one topic at a time.
  • Grouping related sections that a user may want to skip.

When not to use

  • Content the user reads in full, in order. Show it on the page.
  • Switching between views. Use tabs. Use Tabs instead.

Guidelines

Do

  • Write headings as questions or short topic names.
  • Open the most common answer by default when there is one.

Don't

  • Do not hide critical warnings inside a collapsed item.

Accessibility

Roles and attributes

ElementRoleNotes
triggerbuttonaria-expanded follows the panel state, aria-controls names the panel. aria-disabled when disabled.

Keyboard

KeysAction
TabShiftTabMoves between the heading buttons.
EnterSpaceOpens or closes the focused panel.
ArrowDownArrowUpMove focus to the next or previous heading.
  • The trigger is a native button, so Enter and Space work without extra code. Keep the heading text descriptive, since it is the only label.

API

AccordionGroup

Selector: mui-accordion

NameTypeDefaultDescription
multiplebooleanfalse Allow multiple panels open simultaneously. Defaults to single-open. Accepts attribute presence, e.g. <… multiple>.

CSS parts

  • ::part(root)

AccordionItem

Selector: mui-accordion-item

NameTypeDefaultDescription
headingrequiredstring— Visible heading text of the trigger button.
disabledbooleanfalse Disables this item so it cannot be opened. Accepts attribute presence, e.g. <… disabled>.

CSS parts

  • ::part(body)
  • ::part(chevron)
  • ::part(heading)
  • ::part(item)
  • ::part(panel)
  • ::part(trigger)

Tokens

  • --mui-color-border
  • --mui-color-text
  • --mui-color-focus-ring
  • --mui-touch-target
  • --mui-space-3