menumenu_openMDC

Accordion

descriptionREADMEwidgetsDemo

A Material Design 3 Accordion & Expansion Panel component pair inspired by Android / AndroidX (ExpandableListView, PreferenceCategory, MaterialCardView, and Jetpack Compose AnimatedVisibility) patterns.

Usage

<mdc-accordion mode="single" variant="outlined">
    <mdc-expansion-panel headline="Personal details" supporting-text="Name, email, and phone" icon="person" expanded>
        <p>Update your personal information and contact preferences.</p>
        <mdc-button slot="actions" variant="text">Edit</mdc-button>
    </mdc-expansion-panel>
    <mdc-expansion-panel headline="Notifications" supporting-text="Email & push alerts" icon="notifications">
        <p>Choose which notifications you would like to receive.</p>
    </mdc-expansion-panel>
</mdc-accordion>

<mdc-accordion> Attributes

Property Attribute Type Default Description
mode mode 'multiple' | 'single' 'multiple' Whether multiple panels or only one panel can be open at a time.
collapsible collapsible boolean true In 'single' mode, whether the active panel can be collapsed by clicking it.
variant variant 'outlined' | 'elevated' | 'filled' | 'flat' 'outlined' Default visual style propagated to child panels.
size size 'small' | 'medium' | 'large' 'medium' Default header density propagated to child panels.
shape shape 'round' | 'square' 'round' Default corner shape propagated to child panels.
connected connected boolean false Joins child panels into a flush vertical stack.
quick quick boolean false Disables expand/collapse animations on child panels.

<mdc-expansion-panel> Attributes

Property Attribute Type Default Description
expanded expanded boolean false Controls whether the panel body is expanded.
disabled disabled boolean false Disables user interaction.
variant variant 'outlined' | 'elevated' | 'filled' | 'flat' 'outlined' Visual style variant.
size size 'small' | 'medium' | 'large' 'medium' Header density size.
shape shape 'round' | 'square' 'round' Corner shape.
headline headline string '' Header title text.
supportingText supporting-text string '' Header summary/description text.
icon icon string '' Leading Material Symbols icon name.
expandIcon expand-icon string 'expand_more' Trailing expand/collapse icon name.
hideIndicator hide-indicator boolean false Hides the trailing expand indicator.
hideSummaryOnExpand hide-summary-on-expand boolean false Hides supporting-text while expanded.
noDivider no-divider boolean false Hides the bottom divider in flat variant or above actions.
headingLevel heading-level number 0 Optional ARIA heading level (1–6).
quick quick boolean false Disables expand/collapse animations.

Events

  • expansion-panel-toggle: Cancelable event fired before toggling via user click (detail: { expanded }).
  • expansion-panel-expanding / expansion-panel-expanded: Fired on expand start/end.
  • expansion-panel-collapsing / expansion-panel-collapsed: Fired on collapse start/end.
  • accordion-change: Fired on <mdc-accordion> when panel expansion changes (detail: { expandedIndices, expandedPanels, changedPanel, expanded }).

Connected

Code
<div style="display: flex; flex-direction: column; gap: 24px; max-width: 640px;">
    <mdc-accordion connected variant="outlined" mode="single">
        <mdc-expansion-panel headline="General" supporting-text="Language, region, and time zone" icon="tune" hide-summary-on-expand expanded>
            <p style="margin: 0;">Connected panels share borders and round only the outer first/last corners.</p>
        </mdc-expansion-panel>
        <mdc-expansion-panel headline="Privacy & Security" supporting-text="Two-factor authentication" icon="security" hide-summary-on-expand>
            <p style="margin: 0;">Manage passkeys, recovery codes, and active sessions.</p>
        </mdc-expansion-panel>
        <mdc-expansion-panel headline="Storage" supporting-text="12.4 GB of 15 GB used" icon="storage" hide-summary-on-expand>
            <p style="margin: 0;">Review large files and cached media.</p>
        </mdc-expansion-panel>
    </mdc-accordion>
</div>

Mode

Code
<div style="display: flex; flex-direction: column; gap: 24px; max-width: 640px;">
    <mdc-accordion mode="single" variant="outlined">
        <mdc-expansion-panel headline="Step 1: Account" supporting-text="Single-expand mode" icon="person" expanded>
            <p style="margin: 0;">Expanding another panel automatically collapses this one.</p>
        </mdc-expansion-panel>
        <mdc-expansion-panel headline="Step 2: Billing" supporting-text="Payment method" icon="credit_card">
            <p style="margin: 0;">Enter your billing address and card details.</p>
        </mdc-expansion-panel>
        <mdc-expansion-panel headline="Step 3: Review" supporting-text="Disabled panel" icon="check_circle" disabled>
            <p style="margin: 0;">Complete previous steps first.</p>
        </mdc-expansion-panel>
    </mdc-accordion>
</div>

Size

Code
<div style="display: flex; flex-direction: column; gap: 24px; max-width: 640px;">
    <mdc-accordion size="small" variant="filled">
        <mdc-expansion-panel headline="Small density (48px header)" icon="compress">
            <p style="margin: 0;">Compact layout for dense preference lists.</p>
        </mdc-expansion-panel>
    </mdc-accordion>
    <mdc-accordion size="medium" variant="filled">
        <mdc-expansion-panel headline="Medium density (56px header)" icon="view_agenda">
            <p style="margin: 0;">Standard Material 3 expansion panel density.</p>
        </mdc-expansion-panel>
    </mdc-accordion>
    <mdc-accordion size="large" variant="filled">
        <mdc-expansion-panel headline="Large density (72px header)" supporting-text="With supporting summary" icon="expand">
            <p style="margin: 0;">Spacious header layout for prominent sections.</p>
        </mdc-expansion-panel>
    </mdc-accordion>
</div>

Variant

Code
<div style="display: flex; flex-direction: column; gap: 24px; max-width: 640px;">
    <mdc-accordion variant="outlined">
        <mdc-expansion-panel headline="Outlined Panel" supporting-text="Default Material 3 outlined style" icon="palette" expanded>
            <p style="margin: 0;">Outlined panels use a 1px hairline border on a surface background.</p>
        </mdc-expansion-panel>
        <mdc-expansion-panel headline="Second Outlined Panel" supporting-text="With footer actions" icon="settings">
            <p style="margin: 0;">Configure your workspace preferences and notification rules here.</p>
            <mdc-button slot="actions" variant="text">Cancel</mdc-button>
            <mdc-button slot="actions" variant="text">Save</mdc-button>
        </mdc-expansion-panel>
    </mdc-accordion>

    <mdc-accordion variant="elevated">
        <mdc-expansion-panel headline="Elevated Panel" supporting-text="Surface Container Low with shadow" icon="layers">
            <p style="margin: 0;">Elevated panels lift from Level 1 to Level 2 elevation when expanded.</p>
        </mdc-expansion-panel>
    </mdc-accordion>

    <mdc-accordion variant="filled">
        <mdc-expansion-panel headline="Filled Panel" supporting-text="Tonal surface container" icon="inbox">
            <p style="margin: 0;">Filled panels use tonal surface container contrast without borders.</p>
        </mdc-expansion-panel>
    </mdc-accordion>

    <mdc-accordion variant="flat" connected>
        <mdc-expansion-panel headline="Flat Row 1" supporting-text="Android ExpandableListView style" icon="wifi">
            <p style="margin: 0;">Connected to Wi-Fi network.</p>
        </mdc-expansion-panel>
        <mdc-expansion-panel headline="Flat Row 2" supporting-text="Bluetooth & devices" icon="bluetooth">
            <p style="margin: 0;">No paired devices nearby.</p>
        </mdc-expansion-panel>
    </mdc-accordion>
</div>