{
  "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/mds-pref-theme.tsx",
      "encapsulation": "shadow",
      "tag": "mds-pref-theme",
      "docs": "",
      "docsTags": [
        {
          "name": "slot",
          "text": "- Add `mds-pref-theme-item` element/s."
        },
        {
          "name": "category",
          "text": "preferences"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-pref-theme>` web component is the theme-switcher segment of the Magma accessibility preferences panel, usually a direct child of [`<mds-pref>`](../mds-pref/AGENTS.md). It renders a labelled tab trigger that opens a dropdown of selectable named themes and, when a theme is chosen, applies it globally to the document.\n\n#### Semantic Behavior\n\n- **Usually inside `<mds-pref>`**: Placed as a direct slot child of `<mds-pref>`, alongside the other `mds-pref-*` controls; it also works on its own, since it applies and stores the theme by itself. What it gives up on its own is in its mistakes.\n- **Acts as a sub-parent itself**: Its own default slot must contain one or more `mds-pref-theme-item` elements; it drives their selected state so only the active theme is marked selected.\n- **Global theme application**: Selecting an item applies the theme document-wide: it writes `data-theme-name` and the `pref-theme-scheme-*` class on `<html>`.\n- **The theme's own mode**: A theme file can list the colour modes it can be used in (`color.modes`); a theme of one mode declares it in its block of `themes.css`, and the component applies the theme in that mode (`pref-theme-scheme-dark` or `-light`) whatever the item's `scheme` says. The stylesheet of the theme must be on the page when the theme is applied. The storage keeps the item's `scheme`.\n- **Persistence and hydration**: The current name, scheme and corner shape are persisted and restored across reloads: a stored value outranks the matching prop.\n- **Validation**: An invalid theme name (not lowercase kebab-case matching `^[a-z]+(-[a-z]+)*$`) is ignored with a console warning when the theme is applied: nothing is written on `<html>` or stored. So are the reserved names `light`, `dark` and `system` (they are mode values) and `scheme` or `scheme-*` (they would collide with the `pref-theme-scheme-*` classes), a `scheme` other than `light`, `dark` or `all`, and a `corner-shape` outside its keywords. A stored value the component cannot apply is dropped, and the prop is used instead.\n- **Events bubbled up**: Emits `mdsPrefThemeChange` with the `{ name, scheme }` detail on each pick, `scheme` being the one the theme is applied with (the theme's own mode, when it declares one). `<mds-pref-mode>` follows the scheme from `<html>`, with no listener. It also emits `mdsPrefChange` once per change, after applying it: `preference: 'theme'` for a new name or scheme, `'corner-shape'` for a new corner shape. The first application on load and a re-render that changes nothing do not emit it.\n- **Props set after load**: A `name`, `scheme` or `cornerShape` set from a script after load is stored and applied, as a pick is: the stored value outranks the prop only on load. A value the component would not apply is not stored.\n- **Localized label**: The \"Theme\" heading follows the active interface language.\n- **Trigger text**: The closed control shows the `label` of the item for the active theme, the same text the open list shows (localize the items, the trigger follows); when no item matches the active theme it shows the label derived from the name (`dark-blue` -> \"Dark blue\").\n\n#### Properties & Visual Configurations\n\n- **`name`**: The active theme name; it is overridden at runtime by any persisted value. Use it to declare the initial theme when no preference has been stored yet. The named themes are `business`, the base theme, and `editorial` ([`agents/theming.md`](../../../../agents/theming.md)). The default `'default'` is the old name of `business`, kept until the next major, when the default becomes `'business'`: the two names stand for the same theme, so with `name` left out the item `business` is the one marked, and an item named `default` is marked under `business`. `cool` and `warm` are deprecated.\n- **`scheme`**: Constrains the colour modes of the theme to `'light'`, `'dark'`, or `'all'` (default). Pick `'all'` for themes that ship both light and dark palettes; pick `'light'` or `'dark'` to force a single mode for a theme offered in one mode only. A theme that declares its own mode (`color.modes` in its file) needs no `scheme`: its declaration wins.\n- **`size`**: Sets the size (`'sm'` / `'md'`) of the nested tab UI. Inside `<mds-pref>`, set it on the parent: it reaches every `mds-pref-*` segment on load and when it changes, and overwrites the segment's own.\n- **`cornerShape`** (attribute `corner-shape`): The corner geometry of the whole page - `round`, `squircle`, `bevel`, `notch`, `scoop`, `square`, or `default`. It writes `data-corner-shape` on `<html>` and is persisted like the theme; `default` removes the attribute, and leaving the prop unset touches nothing ([`agents/theming.md`](../../../../agents/theming.md)).\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-pref-theme>` component, ordered from most common to most specialized. The examples assume a working knowledge of the preferences system documented in [`agents/theming.md`](../../../../agents/theming.md) and the shared component rules in [`agents/conventions.md`](../../../../agents/conventions.md).\n\n#### Basic Theme Chooser\n\nThe canonical form. Place `<mds-pref-theme>` inside [`<mds-pref>`](../mds-pref/AGENTS.md) and populate its default slot with one [`<mds-pref-theme-item>`](../mds-pref-theme-item/AGENTS.md) per available theme. The item whose `name` matches the active theme (the stored choice, or the parent's `name` on a first visit) starts as selected. The named themes are `business`, the base theme of the management software, and `editorial`, the theme of the publishing side.\n\n```html\n<mds-pref>\n  <mds-pref-theme name=\"business\" scheme=\"all\">\n    <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n    <mds-pref-theme-item label=\"Editoriale\" name=\"editorial\" scheme=\"all\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n```\n\n#### Scheme-Constrained Themes\n\nA theme made for one colour mode says so in its file (`\"modes\": [\"dark\"]` in `color`), and the component applies it in that mode with no attribute on the item. For a theme whose file says nothing, use `scheme=\"light\"` or `scheme=\"dark\"` on a `<mds-pref-theme-item>`. Either way the component writes the scheme on `<html>` and forces that mode even if the user's OS or mode preference asks for the opposite, and `<mds-pref-mode>` shows that mode with its other items locked.\n\n```html\n<mds-pref>\n  <mds-pref-theme name=\"business\" scheme=\"all\">\n    <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n    <!-- light only - dark mode will not activate with this item -->\n    <mds-pref-theme-item label=\"Editoriale chiaro\" name=\"editorial\" scheme=\"light\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n```\n\n#### Listening for the Change Event\n\nReact to the user's selection via `mdsPrefThemeChange`. The event detail carries `{ name, scheme }` - use them to update any app-level state that tracks the active theme.\n\n```html\n<mds-pref>\n  <mds-pref-theme id=\"theme-chooser\" name=\"business\" scheme=\"all\">\n    <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n    <mds-pref-theme-item label=\"Editoriale\" name=\"editorial\" scheme=\"all\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n\n<script>\n  document.querySelector('#theme-chooser').addEventListener('mdsPrefThemeChange', (e) => {\n    console.log('Tema attivo:', e.detail.name, '- Schema:', e.detail.scheme);\n  });\n</script>\n```\n\n#### Declaring the Initial Theme\n\nUse the `name` prop to declare which theme should be active before the user makes a selection. If `localStorage` already holds a persisted value it takes precedence; otherwise the component applies `name` on first render.\n\n```html\n<mds-pref>\n  <!-- First-visit default is \"editorial\" -->\n  <mds-pref-theme name=\"editorial\" scheme=\"all\">\n    <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n    <mds-pref-theme-item label=\"Editoriale\" name=\"editorial\" scheme=\"all\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n```\n\n#### Controlling Item Size\n\nPass `size=\"sm\"` when the preferences panel must fit a compact layout: on `<mds-pref>`, which forwards it to every preference control.\n\n```html\n<mds-pref size=\"sm\">\n  <mds-pref-theme name=\"business\" scheme=\"all\">\n    <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n    <mds-pref-theme-item label=\"Editoriale\" name=\"editorial\" scheme=\"all\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n```\n\n#### Styling Theme Items\n\nStyle theme items only through their public `--mds-pref-theme-item-*` CSS custom properties. Set them on the item host or on a parent selector; name a semantic role, `rgb(var(--magma-<role>))` ([`agents/color.md`](../../../../agents/color.md)), so the colours follow the mode, the theme and the contrast preference.\n\n```css\nmds-pref-theme-item {\n  --mds-pref-theme-item-color-background: rgb(var(--magma-surface-inverse));\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-pref-theme>`. Each entry pairs the wrong form with the right one and a one-line reason. System-wide rules (boolean-as-string, shadow piercing, Tailwind colour 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 Component Outside `<mds-pref>`\n\n`<mds-pref-theme>` is a compound sub-part designed to slot inside [`<mds-pref>`](../mds-pref/AGENTS.md). As a standalone widget it still applies and persists the theme, but it leaves the panel: `<mds-pref>` can no longer forward `size` changes to it. The lock of a single-mode theme on `<mds-pref-mode>` holds either way.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-theme name=\"business\" scheme=\"all\">\n  <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n</mds-pref-theme>\n\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-theme name=\"business\" scheme=\"all\">\n    <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n```\n\n#### Do Not Put Plain Text or Arbitrary HTML in the Default Slot\n\nThe default slot is reserved exclusively for `<mds-pref-theme-item>` elements. Any other content bypasses the component's internal selection management and will not trigger theme application.\n\n```html\n<!-- INCORRECT -->\n<mds-pref>\n  <mds-pref-theme name=\"business\" scheme=\"all\">\n    <button>Gestionale</button>\n    <span>Editoriale</span>\n  </mds-pref-theme>\n</mds-pref>\n\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-theme name=\"business\" scheme=\"all\">\n    <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n    <mds-pref-theme-item label=\"Editoriale\" name=\"editorial\" scheme=\"all\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n```\n\n#### Do Not Use an Invalid Theme Name\n\nThe `name` prop must match the pattern `^[a-z]+(-[a-z]+)*$` (lowercase letters and hyphens only). Any other value - including uppercase, underscores, or spaces - is ignored with a console warning when the component tries to apply the theme on `<html>`: the theme is neither applied nor stored.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-theme name=\"My Theme\" scheme=\"all\">...</mds-pref-theme>\n<mds-pref-theme name=\"my_theme\" scheme=\"all\">...</mds-pref-theme>\n<mds-pref-theme name=\"MyTheme\" scheme=\"all\">...</mds-pref-theme>\n\n<!-- CORRECT -->\n<mds-pref-theme name=\"editorial\" scheme=\"all\">...</mds-pref-theme>\n```\n\n#### Do Not Listen for the Native `change` Event\n\n`<mds-pref-theme>` emits `mdsPrefThemeChange` - a documented custom event with a typed `{ name, scheme }` detail. Listening for the native `change` event will not fire because theme selection is handled entirely inside shadow DOM.\n\n```html\n<!-- INCORRECT -->\n<script>\n  document.querySelector('mds-pref-theme').addEventListener('change', (e) => {\n    console.log(e.target.value); // undefined - wrong event, wrong detail shape\n  });\n</script>\n\n<!-- CORRECT -->\n<script>\n  document.querySelector('mds-pref-theme').addEventListener('mdsPrefThemeChange', (e) => {\n    console.log(e.detail.name, e.detail.scheme);\n  });\n</script>\n```\n\n#### Do Not Give the Parent and the Child Different Sizes\n\n`<mds-pref>` forwards its own `size` to all `mds-pref-*` children, on load and when it changes, and overwrites theirs: a `size` on `<mds-pref-theme>` that differs from the parent's is never shown. Set the size on the parent only.\n\n```html\n<!-- INCORRECT -->\n<mds-pref size=\"sm\">\n  <mds-pref-theme size=\"md\" name=\"default\" scheme=\"all\">\n    <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n\n<!-- CORRECT -->\n<mds-pref size=\"sm\">\n  <mds-pref-theme name=\"business\" scheme=\"all\">\n    <mds-pref-theme-item label=\"Gestionale\" name=\"business\" scheme=\"all\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n```\n"
      },
      "props": [
        {
          "name": "cornerShape",
          "type": "\"bevel\" | \"default\" | \"notch\" | \"round\" | \"scoop\" | \"square\" | \"squircle\" | undefined",
          "complexType": {
            "original": "PreferenceCornerShapeChoiceType",
            "resolved": "\"bevel\" | \"default\" | \"notch\" | \"round\" | \"scoop\" | \"square\" | \"squircle\" | undefined",
            "references": {
              "PreferenceCornerShapeChoiceType": {
                "location": "import",
                "path": "@type/preference",
                "id": "src/type/preference.ts::PreferenceCornerShapeChoiceType",
                "referenceLocation": "PreferenceCornerShapeChoiceType"
              }
            }
          },
          "mutable": true,
          "attr": "corner-shape",
          "reflectToAttr": true,
          "docs": "Specifies the corner geometry of the whole page: one of the `corner-shape`\nkeywords, or `default`.\n\nCorner geometry is theme appearance rather than an accessibility preference,\nwhich is why it lives here next to the theme name and scheme instead of in\n`mds-pref-mode`. Setting it writes `data-corner-shape` on `<html>`, where\nthe generated axis picks both the shape and the radius scale tuned for it.\n\nLeaving it unset touches nothing. Setting it to `default` REMOVES the\nattribute rather than writing today's default into the page, so a project\nthat never chose keeps following the design system when the default changes.",
          "docsTags": [],
          "values": [
            {
              "value": "bevel",
              "type": "string"
            },
            {
              "value": "default",
              "type": "string"
            },
            {
              "value": "notch",
              "type": "string"
            },
            {
              "value": "round",
              "type": "string"
            },
            {
              "value": "scoop",
              "type": "string"
            },
            {
              "value": "square",
              "type": "string"
            },
            {
              "value": "squircle",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "name",
          "type": "string",
          "complexType": {
            "original": "string",
            "resolved": "string",
            "references": {}
          },
          "mutable": true,
          "attr": "name",
          "reflectToAttr": true,
          "docs": "Specifies the theme name attribute\nA string representing the theme name, in lowercase kebab-case.",
          "docsTags": [
            {
              "name": "example",
              "text": "'maggioli-editore'"
            },
            {
              "name": "default",
              "text": "'default'"
            }
          ],
          "default": "'default'",
          "values": [
            {
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "scheme",
          "type": "\"all\" | \"dark\" | \"light\"",
          "complexType": {
            "original": "PreferenceThemeSchemeType",
            "resolved": "\"all\" | \"dark\" | \"light\"",
            "references": {
              "PreferenceThemeSchemeType": {
                "location": "import",
                "path": "@type/preference",
                "id": "src/type/preference.ts::PreferenceThemeSchemeType",
                "referenceLocation": "PreferenceThemeSchemeType"
              }
            }
          },
          "mutable": true,
          "attr": "scheme",
          "reflectToAttr": true,
          "docs": "Specifies the theme scheme which can be 'light', 'dark' or 'all'\nDefault is 'all' which means this theme supporto both light and dark.\nIf you set 'light' means this theme support only light mode and will be forced and shown light colors mode only.\nA theme whose stylesheet declares one mode (`--magma-color-modes`, from `color.modes` of its\nfile) is applied in that mode whatever this says: the theme's own lock wins.",
          "docsTags": [
            {
              "name": "default",
              "text": "'all'"
            }
          ],
          "default": "'all'",
          "values": [
            {
              "value": "all",
              "type": "string"
            },
            {
              "value": "dark",
              "type": "string"
            },
            {
              "value": "light",
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "size",
          "type": "\"md\" | \"sm\" | undefined",
          "complexType": {
            "original": "TabSizeType",
            "resolved": "\"md\" | \"sm\" | undefined",
            "references": {
              "TabSizeType": {
                "location": "import",
                "path": "@type/button",
                "id": "src/type/button.ts::TabSizeType",
                "referenceLocation": "TabSizeType"
              }
            }
          },
          "mutable": false,
          "attr": "size",
          "reflectToAttr": true,
          "docs": "Sets the size of the component items nested inside it",
          "docsTags": [],
          "values": [
            {
              "value": "md",
              "type": "string"
            },
            {
              "value": "sm",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [
        {
          "event": "mdsPrefChange",
          "detail": "MdsPrefChangeEventDetail",
          "bubbles": true,
          "complexType": {
            "original": "MdsPrefChangeEventDetail",
            "resolved": "MdsPrefChangeEventDetail",
            "references": {
              "MdsPrefChangeEventDetail": {
                "location": "import",
                "path": "@event/preference",
                "id": "src/event-detail/preference.ts::MdsPrefChangeEventDetail",
                "referenceLocation": "MdsPrefChangeEventDetail"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when the component is triggered",
          "docsTags": []
        },
        {
          "event": "mdsPrefThemeChange",
          "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 changes the language selected from the click event of the dropdown list item.\nIts `scheme` is the one the theme is applied with: the mode the theme declares, when it\ndeclares one, or else the scheme of the item.",
          "docsTags": []
        }
      ],
      "listeners": [
        {
          "event": "mdsPrefThemeItemSelect",
          "capture": false,
          "passive": false
        }
      ],
      "styles": [],
      "slots": [
        {
          "name": "",
          "docs": "Add `mds-pref-theme-item` element/s."
        }
      ],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-text",
        "mds-tab",
        "mds-tab-item",
        "mds-dropdown"
      ],
      "dependencyGraph": {
        "mds-pref-theme": [
          "mds-text",
          "mds-tab",
          "mds-tab-item",
          "mds-dropdown"
        ],
        "mds-tab-item": [
          "mds-button"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ]
      },
      "storybook": "ui-preferences-theme--docs"
    }
  ]
}
