{
  "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-mode/mds-pref-mode.tsx",
      "encapsulation": "shadow",
      "tag": "mds-pref-mode",
      "docs": "",
      "docsTags": [
        {
          "name": "category",
          "text": "preferences"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-pref-mode>` web component is the mode preference control of the Magma Design System, usually a direct child of the [`<mds-pref>`](../mds-pref/AGENTS.md) panel. It renders a labelled three-way tab (light / system / dark) that lets the user pick a color-scheme mode and 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 mode by itself. What it gives up on its own is in its mistakes.\n- **Selection follows `mode`**: The active tab reflects whichever mode is currently applied, driven by the `mode` prop.\n- **Global mode application**: Selecting a mode applies it document-wide and persists the choice.\n- **Persistence on load**: The applied mode resolves from `mode` -> the stored value -> the `system` default, so a previously chosen mode is restored without an explicit prop.\n- **`mdsPrefChange` event**: Emits `mdsPrefChange` with `{ preference: 'mode' }` once per change, after the new mode is applied; a pick of the mode already active and the first application on load do not emit it. It bubbles up to `<mds-pref>`; a mode change needs no reload, so it raises no reload notice.\n- **Instances stay in sync**: Instances mounted together (a hidden `<mds-pref controller>` and a visible settings panel) share the applied mode: a pick in one is mirrored by the others, which neither apply it again nor emit `mdsPrefChange`. A `pref-mode-*` class written on `<html>` by other code is mirrored the same way.\n- **System mode**: The `system` choice follows the OS `prefers-color-scheme` media query to resolve the effective light/dark scheme.\n- **Theme lock**: Under a theme that can be used in one mode only (`pref-theme-scheme-light` or `-dark` on `<html>`, written by `mds-pref-theme` from the mode the theme declares), the control shows that mode selected and disables the other two items: the page is in that mode whatever was picked. The stored choice is left alone and comes back with a theme of both modes.\n\n#### Properties & Visual Configurations\n\n- **`mode`**: Sets and reflects the active mode (`light`, `dark`, `system`). Leave it unset to inherit the persisted/default mode; set it explicitly to force a starting mode.\n- **`transition`**: Controls the visual switch between schemes. Use `smooth` (default) for a fading neutral overlay that flips the mode mid-fade, `flash` for an instant switch with a brief overlay pulse, or `none` to apply the new mode with no overlay animation. The overlay timing and z-index are tunable through `--mds-pref-mode-overlay-*` CSS custom properties.\n- **`size`**: Sizes the nested tab items (`sm` / `md`). Inside `<mds-pref>`, set it on the parent instead: the parent's `size` reaches every `mds-pref-*` child on load and when it changes, and overwrites the child's own.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-pref-mode>` component, ordered from most common to most specialized. The examples assume a working knowledge of the shared preference system documented in [`agents/theming.md`](../../../../agents/theming.md) and the shared component rules in [`agents/conventions.md`](../../../../agents/conventions.md).\n\n#### Default Usage Inside `mds-pref`\n\nThe canonical form. Slot `<mds-pref-mode>` as a direct child of [`<mds-pref>`](../mds-pref/AGENTS.md) with no extra props. The component restores the user's previously persisted mode automatically on load.\n\n```html\n<mds-pref>\n  <mds-pref-mode></mds-pref-mode>\n</mds-pref>\n```\n\n#### Setting an Initial Mode\n\nPass `mode` to force the selector to start on a specific mode rather than reading from `localStorage`. Useful when the host application controls preference state centrally. The forced mode is also written to `localStorage` on every load, replacing the user's last choice.\n\n```html\n<mds-pref>\n  <mds-pref-mode mode=\"dark\"></mds-pref-mode>\n</mds-pref>\n```\n\n#### Using `system` Mode for OS-Aware Default\n\n`mode=\"system\"` resolves to light or dark based on the OS `prefers-color-scheme` media query. Use this as the explicit starting point when you want the app to follow the OS without the user having to choose.\n\n```html\n<mds-pref>\n  <mds-pref-mode mode=\"system\"></mds-pref-mode>\n</mds-pref>\n```\n\n#### Choosing a Transition Style\n\n`transition` controls the visual effect when switching between schemes. Use `smooth` (default) for a mid-fade overlay that hides the color flip, `flash` for an instant switch with a brief full-screen pulse, or `none` for a hard switch with no animation.\n\n```html\n<!-- Smooth fade (default) -->\n<mds-pref-mode transition=\"smooth\"></mds-pref-mode>\n\n<!-- Instant flash pulse -->\n<mds-pref-mode transition=\"flash\"></mds-pref-mode>\n\n<!-- No animation -->\n<mds-pref-mode transition=\"none\"></mds-pref-mode>\n```\n\n#### Listening for Mode Changes\n\nThe component emits `mdsPrefChange` with `{ preference: 'mode' }` once per change, after the new mode is applied, and not on page load; another instance that mirrors the pick does not emit it. Listen for this event to react in application code - for example to sync a preference state store - and read the current value from the `mode` prop.\n\n```html\n<mds-pref>\n  <mds-pref-mode id=\"mode-selector\"></mds-pref-mode>\n</mds-pref>\n\n<script>\n  document.getElementById('mode-selector').addEventListener('mdsPrefChange', (e) => {\n    console.log('Modalita tema cambiata:', e.detail.preference);\n  });\n</script>\n```\n\n#### Controlling Size via the Parent\n\n`size` is forwarded to the internal tab items. [`<mds-pref>`](../mds-pref/AGENTS.md) forwards its own `size` to every `mds-pref-*` child, on load and when it changes: set it on the parent to keep the panel at one tab size.\n\n```html\n<mds-pref size=\"sm\">\n  <mds-pref-mode></mds-pref-mode>\n  <mds-pref-contrast></mds-pref-contrast>\n</mds-pref>\n```\n\n#### Customizing the Transition Overlay\n\nTune the overlay stacking order via the public `--mds-pref-mode-overlay-z-index` CSS custom property, when the page has layers above the default one; the overlay timing is set by the component. Set it on the host or a parent selector.\n\n```css\nmds-pref-mode {\n  --mds-pref-mode-overlay-z-index: 9000;\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-pref-mode>`. 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 `<mds-pref-mode>` Outside `<mds-pref>`\n\n`<mds-pref-mode>` is a compound child: `<mds-pref>` forwards `size` changes to it. As a standalone widget it still applies and persists the mode, and it still follows a theme of one mode, which it reads from `<html>`; only the forwarding of `size` is lost.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-mode></mds-pref-mode>\n\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-mode></mds-pref-mode>\n</mds-pref>\n```\n\n#### Do Not Set `transition=\"false\"` to Disable the Overlay\n\n`transition` is a string enum, not a boolean. `\"false\"` is not a valid value: it only happens to fall through to the no-overlay branch, with no guarantee across releases. Use `transition=\"none\"` to opt out of the overlay animation.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-mode transition=\"false\"></mds-pref-mode>\n\n<!-- CORRECT -->\n<mds-pref-mode transition=\"none\"></mds-pref-mode>\n```\n\n#### Do Not Listen for Native `change` Events Instead of `mdsPrefChange`\n\nThe component does not emit or bubble native `change` events out of the shadow DOM. Always listen for the documented `mdsPrefChange` custom event.\n\n```html\n<!-- INCORRECT -->\n<script>\n  document.querySelector('mds-pref-mode').addEventListener('change', handler);\n</script>\n\n<!-- CORRECT -->\n<script>\n  document.querySelector('mds-pref-mode').addEventListener('mdsPrefChange', handler);\n</script>\n```\n\n#### Do Not Override Mode Classes on `<html>` Directly\n\nThe component manages `pref-mode-light`, `pref-mode-dark`, and `pref-mode-system` classes on `<html>` itself. Adding or removing these by hand races with the component and will be overwritten on the next mode change. Drive the mode exclusively through the `mode` prop.\n\n```html\n<!-- INCORRECT -->\n<script>\n  document.documentElement.classList.add('pref-mode-dark');\n</script>\n\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-mode mode=\"dark\"></mds-pref-mode>\n</mds-pref>\n```\n\n#### Do Not Size Only One Child of the Panel\n\nSetting `size` on `<mds-pref-mode>` alone when siblings exist produces inconsistent tab sizes across the panel. Set it on `<mds-pref>`, which forwards it to every preference child, on load and when it changes.\n\n```html\n<!-- INCORRECT -->\n<mds-pref>\n  <mds-pref-mode size=\"sm\"></mds-pref-mode>\n  <mds-pref-contrast></mds-pref-contrast>\n</mds-pref>\n\n<!-- CORRECT -->\n<mds-pref size=\"sm\">\n  <mds-pref-mode></mds-pref-mode>\n  <mds-pref-contrast></mds-pref-contrast>\n</mds-pref>\n```\n\n#### Do Not Target the Injected Overlay to Customize It\n\nThe overlay element is injected into `document.body` at runtime with inline styles, which win over a class selector anyway. Do not target it by class name or adjust its properties through JavaScript. Use the public `--mds-pref-mode-overlay-z-index` CSS custom property instead.\n\n```css\n/* INCORRECT */\n.mds-pref-mode-overlay {\n  background-color: black;\n  z-index: 99999;\n}\n\n/* CORRECT */\nmds-pref-mode {\n  --mds-pref-mode-overlay-z-index: 9000;\n}\n```\n"
      },
      "props": [
        {
          "name": "lockedScheme",
          "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": "locked-scheme",
          "reflectToAttr": true,
          "docs": "Locks the mode choice to one mode, `light` or `dark`: the control shows that mode\nselected and disables the other two items, without touching the stored preference,\nwhich comes back when the lock goes. `all` locks nothing. Unset, the control follows\nthe active theme: a theme that can be used in one mode only (`pref-theme-scheme-light`\nor `-dark` on `<html>`, written by `mds-pref-theme` from the mode the theme declares,\n#1274) locks it the same way. Not meant to be set directly.",
          "docsTags": [],
          "values": [
            {
              "value": "all",
              "type": "string"
            },
            {
              "value": "dark",
              "type": "string"
            },
            {
              "value": "light",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "mode",
          "type": "\"dark\" | \"light\" | \"system\" | undefined",
          "complexType": {
            "original": "PreferenceModeType",
            "resolved": "\"dark\" | \"light\" | \"system\" | undefined",
            "references": {
              "PreferenceModeType": {
                "location": "import",
                "path": "@type/preference",
                "id": "src/type/preference.ts::PreferenceModeType",
                "referenceLocation": "PreferenceModeType"
              }
            }
          },
          "mutable": true,
          "attr": "mode",
          "reflectToAttr": true,
          "docs": "Specifies the preference mode",
          "docsTags": [],
          "values": [
            {
              "value": "dark",
              "type": "string"
            },
            {
              "value": "light",
              "type": "string"
            },
            {
              "value": "system",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "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
        },
        {
          "name": "transition",
          "type": "\"flash\" | \"none\" | \"smooth\"",
          "complexType": {
            "original": "PreferenceThemeTransitionType",
            "resolved": "\"flash\" | \"none\" | \"smooth\"",
            "references": {
              "PreferenceThemeTransitionType": {
                "location": "import",
                "path": "@type/preference",
                "id": "src/type/preference.ts::PreferenceThemeTransitionType",
                "referenceLocation": "PreferenceThemeTransitionType"
              }
            }
          },
          "mutable": true,
          "attr": "transition",
          "reflectToAttr": true,
          "docs": "Specifies the transition of switching from a mode to another one",
          "docsTags": [
            {
              "name": "default",
              "text": "'smooth'"
            }
          ],
          "default": "'smooth'",
          "values": [
            {
              "value": "flash",
              "type": "string"
            },
            {
              "value": "none",
              "type": "string"
            },
            {
              "value": "smooth",
              "type": "string"
            }
          ],
          "optional": false,
          "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": []
        }
      ],
      "listeners": [],
      "styles": [
        {
          "name": "--mds-pref-mode-overlay-fadeout-duration",
          "annotation": "prop",
          "docs": "Sets the fadeout duration of the overlay which hides UI color flash on theme change",
          "visibility": "internal"
        },
        {
          "name": "--mds-pref-mode-overlay-show-duration",
          "annotation": "prop",
          "docs": "Sets the show duration of the overlay which hides UI color flash on theme change",
          "visibility": "internal"
        },
        {
          "name": "--mds-pref-mode-overlay-z-index",
          "annotation": "prop",
          "docs": "Sets the z-index of the overlay which hides UI color flash on theme change",
          "visibility": "public"
        }
      ],
      "slots": [],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-text",
        "mds-tab",
        "mds-tab-item"
      ],
      "dependencyGraph": {
        "mds-pref-mode": [
          "mds-text",
          "mds-tab",
          "mds-tab-item"
        ],
        "mds-tab-item": [
          "mds-button"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ]
      },
      "storybook": "ui-preferences-mode--docs"
    }
  ]
}
