{
  "timestamp": "2026-11-19T09:33:56",
  "compiler": {
    "name": "@stencil/core",
    "version": "4.45.4",
    "typescriptVersion": "5.8.3"
  },
  "storybook": "https://magma-design-system.github.io/magma/storybook/",
  "studio": "https://magma-design-system.github.io/magma/studio/",
  "components": [
    {
      "filePath": "src/components/mds-pref-theme-item/mds-pref-theme-item.tsx",
      "encapsulation": "shadow",
      "tag": "mds-pref-theme-item",
      "docs": "",
      "docsTags": [
        {
          "name": "parent",
          "text": "mds-pref-theme"
        }
      ],
      "usage": {
        "1. Description": "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.\n\n#### Semantic Behavior\n\n- **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.\n- **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.\n- **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.\n- **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`).\n- **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.\n\n#### Properties & Visual Configurations\n\n- **`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.\n- **`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.\n- **`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.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-pref-theme-item>` component, ordered from most common to most specialized. The examples assume a working knowledge of the shared component rules in [`agents/conventions.md`](../../../../agents/conventions.md).\n\n#### Basic Usage Inside the Parent\n\n`<mds-pref-theme-item>` must always be a direct child of [`<mds-pref-theme>`](../mds-pref-theme/AGENTS.md). Each item represents one selectable colour theme; the parent manages selection state so all siblings stay in sync.\n\n```html\n<mds-pref-theme name=\"business\" scheme=\"all\">\n  <mds-pref-theme-item name=\"business\" label=\"Gestionale\" scheme=\"all\"></mds-pref-theme-item>\n  <mds-pref-theme-item name=\"editorial\" label=\"Editoriale\" scheme=\"all\"></mds-pref-theme-item>\n</mds-pref-theme>\n```\n\n#### Auto-Derived Label\n\nOmit `label` and let the component generate it from `name`: the first letter is capitalised and hyphens are replaced with spaces. Use this shorthand when the theme name is already human-readable.\n\n```html\n<mds-pref-theme name=\"business\" scheme=\"all\">\n  <!-- renders \"Business\" and \"Editorial\" without explicit label props -->\n  <mds-pref-theme-item name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n  <mds-pref-theme-item name=\"editorial\" scheme=\"all\"></mds-pref-theme-item>\n</mds-pref-theme>\n```\n\n#### Scheme-Specific Themes\n\nSet `scheme` to `\"light\"` or `\"dark\"` when a theme must be offered in a single colour mode only. The parent applies the forced mode when the item is selected.\n\n```html\n<mds-pref-theme name=\"business\" scheme=\"all\">\n  <!-- this theme works in both modes -->\n  <mds-pref-theme-item name=\"business\" label=\"Gestionale\" scheme=\"all\"></mds-pref-theme-item>\n\n  <!-- offered light-only; selecting it locks the UI in light mode -->\n  <mds-pref-theme-item name=\"editorial\" label=\"Editoriale chiaro\" scheme=\"light\"></mds-pref-theme-item>\n</mds-pref-theme>\n```\n\n#### Listening to the Selection Event\n\nAttach a listener for `mdsPrefThemeItemSelect` when you need to react to a selection at the item level - for example to log analytics. The detail carries `{ name, scheme }`. Normally the parent handles theme application automatically; only listen at this level for side-effects.\n\n```html\n<mds-pref-theme name=\"business\" scheme=\"all\">\n  <mds-pref-theme-item name=\"business\" label=\"Gestionale\" scheme=\"all\"></mds-pref-theme-item>\n  <mds-pref-theme-item name=\"editorial\" label=\"Editoriale\" scheme=\"all\"></mds-pref-theme-item>\n</mds-pref-theme>\n\n<script>\n  document.querySelectorAll('mds-pref-theme-item').forEach((item) => {\n    item.addEventListener('mdsPrefThemeItemSelect', (e) => {\n      console.log('Tema selezionato:', e.detail.name, 'schema:', e.detail.scheme);\n    });\n  });\n</script>\n```\n\n#### Setting the Initially Selected Item\n\nDeclare it on the parent, not with `selected`: when it loads, `<mds-pref-theme>` marks the item whose `name` matches the active theme (the stored choice, or its own `name` on a first visit) and overwrites any `selected` written in the markup.\n\n```html\n<mds-pref-theme name=\"editorial\" scheme=\"all\">\n  <mds-pref-theme-item name=\"business\" label=\"Gestionale\" scheme=\"all\"></mds-pref-theme-item>\n  <mds-pref-theme-item name=\"editorial\" label=\"Editoriale\" scheme=\"all\"></mds-pref-theme-item>\n</mds-pref-theme>\n```\n\n#### CSS Customization via Documented Properties\n\nOverride the swatch only through the public `--mds-pref-theme-item-color-background` CSS custom property, the background behind the preview dots; the dots themselves are painted by the component. Set it on the host element or a parent selector and name a semantic role for the colour value, `rgb(var(--magma-<role>))` ([`agents/color.md`](../../../../agents/color.md)), so mode, theme and contrast keep working. It replaces the preview of the theme the item names.\n\n```css\n/* override the swatch background of one theme item */\nmds-pref-theme-item[name=\"editorial\"] {\n  --mds-pref-theme-item-color-background: rgb(var(--magma-wash-strong));\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-pref-theme-item>`. Each entry pairs the wrong form with the right one and a one-line reason. System-wide rules (boolean-as-string, shadow piercing, Tailwind color utilities, raw native event listening) live in [`agents/mistakes.md`](../../../../agents/mistakes.md) - they apply here too but are not repeated.\n\n#### Do Not Use the Item Outside Its Parent\n\n`<mds-pref-theme-item>` is a compound child that must be a direct slot child of [`<mds-pref-theme>`](../mds-pref-theme/AGENTS.md). Used standalone it emits selection events that are never handled, and it never receives coordinated deselection of siblings.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-theme-item name=\"editorial\" label=\"Editoriale\" scheme=\"all\"></mds-pref-theme-item>\n\n<!-- CORRECT -->\n<mds-pref-theme name=\"business\" scheme=\"all\">\n  <mds-pref-theme-item name=\"editorial\" label=\"Editoriale\" scheme=\"all\"></mds-pref-theme-item>\n</mds-pref-theme>\n```\n\n#### Do Not Set `selected` Manually to Coordinate Multi-Item State\n\nSetting `selected` on one item does not deselect the others - the parent is the only actor that can coordinate the whole group. When it loads it marks only the item matching the active theme, overwriting the `selected` in the markup; a value set later from script leaves several items marked. Drive initial selection through the parent's `name` prop or by letting the user click.\n\n```html\n<!-- INCORRECT - the parent overwrites both on load and marks \"default\" -->\n<mds-pref-theme name=\"business\" scheme=\"all\">\n  <mds-pref-theme-item name=\"business\" label=\"Gestionale\" scheme=\"all\"></mds-pref-theme-item>\n  <mds-pref-theme-item name=\"editorial\" label=\"Editoriale\" scheme=\"all\" selected></mds-pref-theme-item>\n</mds-pref-theme>\n\n<!-- CORRECT - set the active theme on the parent; it marks the matching child -->\n<mds-pref-theme name=\"editorial\" scheme=\"all\">\n  <mds-pref-theme-item name=\"business\" label=\"Gestionale\" scheme=\"all\"></mds-pref-theme-item>\n  <mds-pref-theme-item name=\"editorial\" label=\"Editoriale\" scheme=\"all\"></mds-pref-theme-item>\n</mds-pref-theme>\n```\n\n#### Do Not Listen for Native `click` Instead of the Component Event\n\nA raw `click` carries no `detail`: you have to read `name` back from the element, and you lose the `scheme`. Listen for the documented `mdsPrefThemeItemSelect` event instead, whose detail carries `{ name, scheme }`.\n\n```html\n<!-- INCORRECT -->\n<script>\n  document.querySelector('mds-pref-theme-item').addEventListener('click', (e) => {\n    applyTheme(e.target.getAttribute('name'));\n  });\n</script>\n\n<!-- CORRECT -->\n<script>\n  document.querySelector('mds-pref-theme-item').addEventListener('mdsPrefThemeItemSelect', (e) => {\n    applyTheme(e.detail.name);\n  });\n</script>\n```\n\n#### Do Not Pierce Shadow DOM to Style the Inner Button\n\nThe supported customization surface is the public `--mds-pref-theme-item-color-background` CSS custom property. Targeting internal selectors or `::part()` names not present in this component's public API couples your code to the implementation and will break on minor releases.\n\n```css\n/* INCORRECT */\nmds-pref-theme-item >>> mds-button {\n  font-weight: bold;\n}\nmds-pref-theme-item .theme-preview {\n  border: 2px solid red;\n}\n\n/* CORRECT */\nmds-pref-theme-item[name=\"editorial\"] {\n  --mds-pref-theme-item-color-background: rgb(var(--magma-wash-strong));\n}\n```\n\n#### Do Not Use an Invalid `scheme` Value\n\n`scheme` only accepts `\"all\"`, `\"light\"`, or `\"dark\"`. Other strings are ignored by the parent with a console warning: picking the item applies and stores nothing, so the theme does not change at all.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-theme-item name=\"editorial\" scheme=\"light-only\"></mds-pref-theme-item>\n<mds-pref-theme-item name=\"business\" scheme=\"night\"></mds-pref-theme-item>\n\n<!-- CORRECT -->\n<mds-pref-theme-item name=\"editorial\" scheme=\"light\"></mds-pref-theme-item>\n<mds-pref-theme-item name=\"business\" scheme=\"dark\"></mds-pref-theme-item>\n```\n"
      },
      "props": [
        {
          "name": "label",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": true,
          "attr": "label",
          "reflectToAttr": true,
          "docs": "Specifies the theme name",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "name",
          "type": "string",
          "complexType": {
            "original": "string",
            "resolved": "string",
            "references": {}
          },
          "mutable": false,
          "attr": "name",
          "reflectToAttr": true,
          "docs": "Specifies the theme name; the swatch shows the preview that theme publishes,\n`--magma-preview-<name>-wash` and `--magma-preview-<name>-accent`",
          "docsTags": [
            {
              "name": "example",
              "text": "'editorial'"
            },
            {
              "name": "default",
              "text": "'default'"
            }
          ],
          "default": "'default'",
          "values": [
            {
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "scheme",
          "type": "\"all\" | \"dark\" | \"light\" | undefined",
          "complexType": {
            "original": "PreferenceThemeSchemeType",
            "resolved": "\"all\" | \"dark\" | \"light\" | undefined",
            "references": {
              "PreferenceThemeSchemeType": {
                "location": "import",
                "path": "@type/preference",
                "id": "src/type/preference.ts::PreferenceThemeSchemeType",
                "referenceLocation": "PreferenceThemeSchemeType"
              }
            }
          },
          "mutable": false,
          "attr": "scheme",
          "reflectToAttr": true,
          "docs": "Specifies the theme scheme which can be 'light', 'dark' or 'all'",
          "docsTags": [
            {
              "name": "default",
              "text": "'all'"
            }
          ],
          "default": "'all'",
          "values": [
            {
              "value": "all",
              "type": "string"
            },
            {
              "value": "dark",
              "type": "string"
            },
            {
              "value": "light",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "selected",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "selected",
          "reflectToAttr": true,
          "docs": "Specifies if the element is selected",
          "docsTags": [
            {
              "name": "default",
              "text": "false"
            }
          ],
          "default": "false",
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [
        {
          "event": "mdsPrefThemeItemSelect",
          "detail": "MdsPrefThemeEventDetail",
          "bubbles": true,
          "complexType": {
            "original": "MdsPrefThemeEventDetail",
            "resolved": "MdsPrefThemeEventDetail",
            "references": {
              "MdsPrefThemeEventDetail": {
                "location": "import",
                "path": "@event/theme",
                "id": "src/event-detail/theme.ts::MdsPrefThemeEventDetail",
                "referenceLocation": "MdsPrefThemeEventDetail"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when the component trigger the language",
          "docsTags": []
        }
      ],
      "listeners": [],
      "styles": [
        {
          "name": "--mds-pref-theme-item-color-background",
          "annotation": "prop",
          "docs": "Background color of a theme item: the wash of the theme it names.",
          "visibility": "public"
        },
        {
          "name": "--mds-pref-theme-item-color-status-error",
          "annotation": "prop",
          "docs": "Color representing an error status for a theme item.",
          "visibility": "internal"
        },
        {
          "name": "--mds-pref-theme-item-color-status-success",
          "annotation": "prop",
          "docs": "Color representing a success status for a theme item.",
          "visibility": "internal"
        },
        {
          "name": "--mds-pref-theme-item-color-status-warning",
          "annotation": "prop",
          "docs": "Color representing a warning status for a theme item.",
          "visibility": "internal"
        },
        {
          "name": "--mds-pref-theme-item-color-variant-primary",
          "annotation": "prop",
          "docs": "Color for the primary variant item: the accent of the theme it names.",
          "visibility": "internal"
        }
      ],
      "slots": [],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-button"
      ],
      "dependencyGraph": {
        "mds-pref-theme-item": [
          "mds-button"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ]
      },
      "storybook": "ui-preferences-theme-item--docs"
    }
  ]
}
