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

# mds-details

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

The `<mds-details>` web component is the disclosure widget of the Magma Design System: a collapsible block with a clickable header that shows or hides its content on demand. It is the styled, accessible equivalent of the native HTML `<details>`/`<summary>` pair, structured into dedicated `title`, `icon`, `action` and content regions.

#### Semantic Behavior

- **Open/closed state**: The `opened` prop expands or collapses the content region with a transition.
- **Header activation**: Clicking the header or the leading icon toggles the open state, and the header is keyboard-activatable with Enter and Space.
- **Closed content**: While closed, the content is hidden from the tab order and from assistive technologies, not only from the eye; it shows for the whole opening and closing animation.
- **Change event**: Each user toggle emits `mdsDetailsChange` carrying the new boolean open state; changing `opened` from code emits nothing.
- **Icon slot presence**: The leading icon area auto-hides when no `icon` slot is provided.
- **Default slot vs. named slots**: The default (unnamed) slot is the collapsible body. The `title` slot is the always-visible header label, `icon` is the optional leading glyph, and `action` is a footer region inside the expandable content meant for action controls.

#### Properties & Visual Configurations

This component intentionally exposes a single behavioral prop. Visual surface is driven through slots and the documented shadow parts (`header`, `title`, `content`) rather than through variant/tone props: the component has no public CSS custom property.

- **`opened`** sets the expanded state. Set it to pre-expand the block on first render, or change it to open / close the block from code. A user toggle writes it back too (property and reflected attribute), so it always holds the current state.

#### Other behavioral props

- The **`title`** slot is recommended to hold an `mds-text`; the **`icon`** slot an `mds-icon`; and the **`action`** slot an `mds-button` for the primary action tied to the disclosed content.

## 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-details--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 |
| --- | --- | --- | --- | --- |
| `opened` | `opened` | `boolean` | `false` | Specifies if the component is opened |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsDetailsChange` | `boolean` | Emits when the component is opened |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `text string`, `HTML elements` or `components` to this slot. |
| `action` | Add `HTML elements` or `components`, it is **recommended** to use `mds-button` element. |
| `icon` | Insert an icon image, it can be `HTML elements` or `components`, it is **recommended** to add `mds-icon` element. |
| `title` | Add a `text string`, `HTML elements` or `components`, it is **recommended** to use `mds-text` element. |

## Parts

| Part | Description |
| --- | --- |
| `content` | The content wrapper of the default and `action` slots |
| `header` | The header of the component |
| `title` | The title of the component |

## CSS custom properties

None is public: its 3 custom properties are internal and may change in any release. Style it with its props, its parts and the semantic roles.
