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

# mds-pref-theme-item

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

The `<mds-pref-theme-item>` web component is a single selectable theme entry inside the [`<mds-pref-theme>`](../mds-pref-theme/AGENTS.md) preference picker. It renders as a borderless button that pairs a color-swatch preview of the theme with its label.

#### Semantic Behavior

- **Compound child only**: Must be placed as a direct default-slot child of `<mds-pref-theme>`; it is not used standalone or mixed with other child component types.
- **Selection is parent-driven**: On click each item emits `mdsPrefThemeItemSelect` (carrying `{ name, scheme }`), and the parent responds by clearing the siblings and selecting the clicked one. Setting `selected` directly on a single item does not coordinate the others.
- **Click bubbles up**: The emitted event is what the parent listens to in order to apply the theme to the document and persist the choice.
- **Auto-derived label**: If `label` is omitted, it is generated from `name` by capitalizing the first letter and replacing hyphens with spaces (e.g. `maggioli-editore` becomes `Maggioli editore`).
- **Preview of the theme it names**: The preview background and the primary dot show the wash and the accent of the theme named by `name`, which the styles of that theme publish as `--magma-preview-<name>-wash` and `--magma-preview-<name>-accent` (`themes.css` does for every theme Magma ships), so each item of the picker shows its own theme whatever the active one. The success, warning and error dots are the page's status emphases, which no theme retints. A theme that publishes no preview shows the active theme. The `--mds-pref-theme-item-*` CSS custom properties paint all of it and still override it.

#### Properties & Visual Configurations

- **`name`**: The theme identifier reported to the parent and matched against the parent's active `name` to compute initial selection. Use a simple or kebab-case string; the named themes are `business`, the base theme, and `editorial` ([`agents/theming.md`](../../../../agents/theming.md)). `default`, `cool` and `warm` still work and are deprecated: they leave at the next major. The parent validates the lowercase/kebab format and ignores an invalid name with a console warning.
- **`scheme`**: Declares which color schemes the theme supports - `all` (default, both light and dark), or `light` / `dark` to force a single mode. This value travels with the selection event and is applied by the parent when the item is chosen, unless the theme declares its own mode in its stylesheet (`color.modes` of its file), which wins.
- **`selected`**: Reflects whether this item is the active theme. The parent sets it on every item when it loads and on each pick, so a value set by hand is overwritten.

## 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-preferences-theme-item--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 |
| --- | --- | --- | --- | --- |
| `label` | `label` | `string \| undefined` | - | Specifies the theme name |
| `name` | `name` | `string` | `'default'` | Specifies the theme name; the swatch shows the preview that theme publishes, `--magma-preview-<name>-wash` and `--magma-preview-<name>-accent` |
| `scheme` | `scheme` | `"all" \| "dark" \| "light" \| undefined` | `'all'` | Specifies the theme scheme which can be 'light', 'dark' or 'all' |
| `selected` | `selected` | `boolean \| undefined` | `false` | Specifies if the element is selected |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsPrefThemeItemSelect` | `MdsPrefThemeEventDetail` | Emits when the component trigger the language |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-pref-theme-item-color-background` | Background color of a theme item: the wash of the theme it names. |

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

## Dependencies

Uses: `mds-button`.
