<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-accordion/ in the magma monorepo (usage/*.md and the
  component's JSDoc). Regenerated on every stencil build (scripts/component-docs.ts).
-->

# mds-accordion

> `@maggioli-design-system/magma` 2.15.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.

The `<mds-accordion>` web component is the compound container of the Magma Design System that groups and orchestrates a set of collapsible `<mds-accordion-item>` panels. It acts as the coordination layer that decides which children are selected.

#### Semantic Behavior

- **Compound parent/child**: The default slot accepts only `<mds-accordion-item>` elements.
- **Single vs. multiple selection**: By default opening one item collapses the others. With `multiple` set, any number of children may stay open at once and selection state is reported as a comma-separated list of indices.
- **Mandatory selection**: When `disable-close` is set, the user cannot collapse the currently open item by clicking it again - one panel always remains open.
- **Emitted event**: `mdsAccordionChange` once for every change of the open items, opening and closing alike, carrying the live `children` NodeList and the `selected` index/indices as a string (empty when none is open). A click that `disable-close` turns down changes nothing and emits nothing.

#### Properties & Visual Configurations

This component has no shared `variant` / `tone` / `size` props; its two booleans control selection semantics rather than appearance.

#### Other behavioral props

- **`multiple`** switches the group from accordion behavior (one panel at a time) to independent toggles, allowing several panels open simultaneously.
- **`disableClose`** prevents the active panel from being dismissed; set it to force at least one panel to stay expanded at all times.

Per-panel presentation - the visible `label`, the title style `typography`, the level `tag` of the title in the outline of the page, and the slotted body content - is configured on each `<mds-accordion-item>` child, not on the accordion itself.

## Read next

- [`examples.md`](examples.md) - correct usage, from the most common case
- [`mistakes.md`](mistakes.md) - the wrong forms, each with the right one
- [Storybook](https://magma-design-system.github.io/magma/storybook/?path=/docs/ui-accordion--docs) - the live examples, in the published Storybook of `main`
- [`conventions.md`](../../../../agents/conventions.md), [`variants.md`](../../../../agents/variants.md), [`mistakes.md`](../../../../agents/mistakes.md) - the rules shared by every component

## Props

| Prop | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `disableClose` | `disable-close` | `boolean \| undefined` | `false` | Prevents the user from closing the currently open item, forcing at least one panel to stay expanded |
| `multiple` | `multiple` | `boolean \| undefined` | `false` | Choose if multiple siblings can be selected simultaneously |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsAccordionChange` | `MdsAccordionEventDetail` | Emits when the component attribute selected is changed |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `mds-accordion-item` element/s. |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-accordion-color` | Sets the text-color of the component children mds-accordion-item |
| `--mds-accordion-padding-selected` | Sets the vertical padding of the component children mds-accordion-item when it's selected |
| `--mds-accordion-padding-unselected` | Sets the vertical padding of the component children mds-accordion-item when it's unselected |

Only these are public. Its other 4 are internal: they may change in any release, do not set them.
