Accordion

Material Design 3-styled accordion / expansion panel web components (lit-material-accordion, lit-material-accordion-panel).

  • 3.0 KB gzipped
  • @lit-material/accordion 0.1.0
  • Renders on the server

Example

Install

npm install @lit-material/accordion @lit-material/tokens
import "@lit-material/accordion";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-accordion-panel>

A single collapsible panel — a disclosure widget (header button + content region) following the WAI-ARIA [Accordion](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) pattern. Works standalone (no wrapping lit-material-accordion required); grouped inside one, the accordion adds single-vs-multi-expand policy and Up/Down/ Home/End roving focus across panel headers.

Properties

PropertyAttributeTypeDefaultDescription
expandedexpandedbooleanfalse
disableddisabledbooleanfalse
dividerdividerbooleanfalseRenders a hairline divider below the panel — handy for a flush-stacked group without a wrapping accordion.

Events

EventDescription
toggleFires when expanded changes via user interaction (clicking or activating the header), with detail: { expanded: boolean }.

Slots

SlotDescription
headerThe header's label content.
leadingAn optional icon before the header label.
defaultThe panel's body content.

CSS parts

PartDescription
headerThe header button (background/padding).
rippleThe state-layer element the hover/press feedback is drawn on.
focus-ringThe focus indicator element.
chevronThe expand/collapse indicator icon.
contentThe content region.

<lit-material-accordion>

Groups lit-material-accordion-panel elements, adding single-vs-multi expand policy and Up/Down/Home/End roving focus across panel headers, per the WAI-ARIA [Accordion](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) pattern. A panel works fine standalone without this wrapper — this only adds cross-panel coordination.

Properties

PropertyAttributeTypeDefaultDescription
multimultibooleanfalseAllows more than one panel to be expanded at once. Default: expanding a panel collapses any other open one.

Slots

SlotDescription
defaultlit-material-accordion-panel elements.

CSS parts

PartDescription
accordionThe container.

Source on GitHub npm