{
  "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/mds-pref.tsx",
      "encapsulation": "shadow",
      "tag": "mds-pref",
      "docs": "",
      "docsTags": [
        {
          "name": "name",
          "text": "Pref"
        },
        {
          "name": "description",
          "text": "This component is based on MdsTab component pattern"
        },
        {
          "name": "overview",
          "text": " <mds-text>Accessibility preferences in web browsers allow users to customize their navigation to improve readability, interaction, and usability. Common options include dark mode, text resizing, screen reader support, keyboard navigation, and blocking animated content. These settings help people with visual, hearing, motor, or cognitive disabilities experience the web more effectively and inclusively.</mds-text>"
        },
        {
          "name": "tags",
          "text": "pattern, user, tab"
        },
        {
          "name": "slot",
          "text": "- Add `mds-pref-animation`, `mds-pref-consumption`, `mds-pref-contrast`, `mds-pref-language`, `mds-pref-mode` or `mds-pref-theme` element/s."
        },
        {
          "name": "example",
          "text": "<mds-pref>\n<mds-pref-animation></mds-pref-animation>\n<mds-pref-consumption></mds-pref-consumption>\n<mds-pref-contrast></mds-pref-contrast>\n<mds-pref-mode></mds-pref-mode>\n<mds-pref-theme></mds-pref-theme>\n<mds-pref-language>\n<mds-pref-language-item code=\"it\"></mds-pref-language-item>\n<mds-pref-language-item code=\"en\"></mds-pref-language-item>\n</mds-pref-language>\n</mds-pref>"
        },
        {
          "name": "category",
          "text": "preferences"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-pref>` web component is the accessibility-preferences panel of the Magma Design System: a compound parent that groups user-facing settings (animation, consumption, contrast, theme, language) so people can tune readability, motion, and language for their session. It acts as the coordinator for the `mds-pref-*` children slotted inside it.\n\n#### Semantic Behavior\n\n- **Compound parent**: Expects `mds-pref-animation`, `mds-pref-consumption`, `mds-pref-contrast`, `mds-pref-mode`, `mds-pref-theme` and/or `mds-pref-language` children in its default slot; it owns no preference UI of its own beyond coordination (it forwards `size`, flags the document and asks for a reload). The lock of a single-mode theme on `mds-pref-mode` needs no parent: the mode control reads it from `<html>`.\n- **Size propagation**: `size` cascades down to every nested `mds-pref-*` child, on load, on every change and to the children added later; without a `size` on the panel each child keeps its own.\n- **Reload notice**: The panel shows an inline caption prompting the user to refresh the page when a preference that cannot apply live (`consumption` or `language`) changes after load. A `controller` panel, which is hidden, shows none.\n- **Live language**: Magma components follow `<html lang>` at once; the content of the application may not, which is why a change of language asks for a reload. An application that translates its own content as `<html lang>` changes says so with `live-language`, and the panel asks for no reload after a change of language (a change of consumption still asks).\n- **Document flag**: While at least one `<mds-pref>` is on the page, `<html>` carries `data-magma-pref`, which turns off the styles' fallback to the OS preferences; it is removed only when the last instance leaves the page, so a settings page that unmounts its own panel leaves the app controller in charge. Moving a panel in the DOM (between a sidebar and a menu, or with a client router that keeps it across pages) keeps the flag and the reload notice.\n- **Live language sync**: When a `language` change is emitted, the panel re-resolves its own locale so the reload notice is shown in the newly selected language.\n\n#### Properties & Visual Configurations\n\n`size` is one of the shared tab sizes and is forwarded to children rather than styling the host directly - set it on the parent and it reaches every child.\n\n#### Other behavioral props\n\n- **`live-language`** tells the panel the application follows `<html lang>` on its own, so a change of language shows no reload notice.\n- **`controller`** switches the component from a visible on-DOM panel into a headless controller that applies and reacts to preferences without rendering UI; in this mode it drives document-level preference state without a visible panel.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-pref>` 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#### Full Preferences Panel\n\nThe canonical form: slot every `mds-pref-*` control directly inside `<mds-pref>`. No extra wiring is needed: the mode control follows the active theme by itself (a theme of one mode locks it to that mode).\n\n```html\n<mds-pref>\n  <mds-pref-mode></mds-pref-mode>\n  <mds-pref-theme>\n    <mds-pref-theme-item name=\"default\"></mds-pref-theme-item>\n    <mds-pref-theme-item name=\"cool\"></mds-pref-theme-item>\n  </mds-pref-theme>\n  <mds-pref-contrast></mds-pref-contrast>\n  <mds-pref-animation></mds-pref-animation>\n  <mds-pref-consumption></mds-pref-consumption>\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Partial Panel - Subset of Controls\n\nSlot only the controls your application needs. `<mds-pref>` renders whatever children are present; omitted controls are simply absent.\n\n```html\n<!-- Accessibility-only panel: contrast and animation controls -->\n<mds-pref>\n  <mds-pref-contrast></mds-pref-contrast>\n  <mds-pref-animation></mds-pref-animation>\n</mds-pref>\n```\n\n#### Controlling Size\n\nThe parent's `size` drives all child controls at once, on load and when it changes.\n\n```html\n<!-- Compact panel for a sidebar or popover -->\n<mds-pref size=\"sm\">\n  <mds-pref-mode></mds-pref-mode>\n  <mds-pref-contrast></mds-pref-contrast>\n  <mds-pref-animation></mds-pref-animation>\n</mds-pref>\n```\n\n#### Headless Controller Mode\n\nSet the `controller` boolean attribute when you need the preference engine to apply saved preferences from `localStorage` on page load without rendering any visible UI. The host is hidden via CSS (`display: none`) and still activates all child preference controls.\n\n```html\n<!-- Place in <body>; the panel is invisible but activates stored preferences -->\n<mds-pref controller>\n  <mds-pref-mode></mds-pref-mode>\n  <mds-pref-contrast></mds-pref-contrast>\n  <mds-pref-animation></mds-pref-animation>\n  <mds-pref-consumption></mds-pref-consumption>\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Language Selector with Multiple Languages\n\n`<mds-pref-language>` requires its child `<mds-pref-language-item>` elements to be present; the items are not self-generating. Pass language codes supported by your application.\n\n```html\n<mds-pref>\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"el\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"es\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n\n#### Reload Notice Handling\n\n`<mds-pref>` shows an inline caption telling the user to refresh the page after a `consumption` or `language` change: nothing to wire. It shows for a change made after the panel loaded, so the stored choices the controls apply on load raise no notice; a `controller` panel is hidden and shows none.\n\n#### An Application That Follows the Language Live\n\nWhen the application translates its own content as `<html lang>` changes (it observes the attribute, or re-renders on `mdsPrefLanguageChange`), add `live-language`: a change of language then needs no reload, and the panel asks for none. A change of consumption still asks.\n\n```html\n<mds-pref live-language>\n  <mds-pref-mode></mds-pref-mode>\n  <mds-pref-language>\n    <mds-pref-language-item code=\"it\"></mds-pref-language-item>\n    <mds-pref-language-item code=\"en\"></mds-pref-language-item>\n  </mds-pref-language>\n</mds-pref>\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-pref>`. 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 Place Non-Pref Children in the Default Slot\n\nThe default slot accepts only `mds-pref-animation`, `mds-pref-consumption`, `mds-pref-contrast`, `mds-pref-language`, `mds-pref-mode` and `mds-pref-theme` children. Other elements are outside the documented content: they render as extra rows of the panel and take part in no coordination.\n\n```html\n<!-- INCORRECT -->\n<mds-pref>\n  <div class=\"custom-section\">Tema</div>\n  <mds-pref-mode></mds-pref-mode>\n</mds-pref>\n\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-mode></mds-pref-mode>\n</mds-pref>\n```\n\n#### Do Not Use `mds-pref-*` Children Outside `<mds-pref>`\n\nEach control applies and stores its own preference, but the coordination between the controls of a panel lives in the parent: only the parent forwards `size` changes and sets the `data-magma-pref` flag that turns off the fallback to the OS preferences. Group the controls of a panel in `<mds-pref>`.\n\n```html\n<!-- INCORRECT -->\n<mds-pref-mode></mds-pref-mode>\n<mds-pref-theme>\n  <mds-pref-theme-item name=\"default\"></mds-pref-theme-item>\n  <mds-pref-theme-item name=\"cool\"></mds-pref-theme-item>\n</mds-pref-theme>\n\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-mode></mds-pref-mode>\n  <mds-pref-theme>\n    <mds-pref-theme-item name=\"default\"></mds-pref-theme-item>\n    <mds-pref-theme-item name=\"cool\"></mds-pref-theme-item>\n  </mds-pref-theme>\n</mds-pref>\n```\n\n#### Do Not Set `controller=\"false\"` to Turn Off Controller Mode\n\n`controller` is a boolean attribute, and a false boolean is an absent attribute ([`agents/conventions.md`](../../../../agents/conventions.md)). The runtime parses the string `\"false\"` as `false`, so the panel shows, but the attribute is still on the element until the first render, so `[controller]` attribute selectors (the one that hides the panel included) and any code that reads the attribute see it set. Remove the attribute entirely to switch back to visible mode.\n\n```html\n<!-- INCORRECT -->\n<mds-pref controller=\"false\">\n  <mds-pref-mode></mds-pref-mode>\n</mds-pref>\n\n<!-- CORRECT -->\n<mds-pref>\n  <mds-pref-mode></mds-pref-mode>\n</mds-pref>\n```\n\n#### Do Not Listen for the Native `change` Event to Detect Preference Changes\n\nThe controls fire no native `change` event. Use the documented `mdsPrefChange` event emitted by each `mds-pref-*` child: it fires once per change, not on page load, and carries only the `preference` name in `detail`, so read the new value from the child.\n\n```html\n<!-- INCORRECT -->\n<script>\n  document.querySelector('mds-pref').addEventListener('change', (e) => {\n    console.log(e);\n  });\n</script>\n\n<!-- CORRECT -->\n<script>\n  document.querySelector('mds-pref-mode').addEventListener('mdsPrefChange', (e) => {\n    console.log(e.detail.preference);\n  });\n</script>\n```\n"
      },
      "props": [
        {
          "name": "controller",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": true,
          "attr": "controller",
          "reflectToAttr": true,
          "docs": "Sets if the component works as hidden element controller instead as UI element, visible on the DOM",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "liveLanguage",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "live-language",
          "reflectToAttr": true,
          "docs": "Tells the panel that the application follows `<html lang>` on its own, translating its\ncontent as the language changes, so a change of language needs no reload and shows no notice",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "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
        }
      ],
      "methods": [],
      "events": [],
      "listeners": [
        {
          "event": "mdsPrefChange",
          "capture": false,
          "passive": false
        }
      ],
      "styles": [],
      "slots": [
        {
          "name": "",
          "docs": "Add `mds-pref-animation`, `mds-pref-consumption`, `mds-pref-contrast`, `mds-pref-language`, `mds-pref-mode` or `mds-pref-theme` element/s."
        }
      ],
      "parts": [],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-text"
      ],
      "dependencyGraph": {
        "mds-pref": [
          "mds-text"
        ]
      },
      "storybook": "ui-preferences--docs"
    }
  ]
}
