{
  "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-input-field/mds-input-field.tsx",
      "encapsulation": "shadow",
      "tag": "mds-input-field",
      "docs": "This is a web-component from Maggioli Design System [Magma](https://magma.maggiolicloud.it), built with StencilJS, TypeScript, Storybook. It's based on the web-component standard and it's designed to be agnostic from the JavaScript framework you are using.",
      "docsTags": [
        {
          "name": "slot",
          "text": "- Add one `mds-input` or `mds-input-date`: the field names it with `label` and shows its\nvalidation errors in `message`. Another control, a native `<input>` among them, gets the name\nbut no validation messages."
        },
        {
          "name": "part",
          "text": "content - The wrapper of the default slot, above the message"
        },
        {
          "name": "category",
          "text": "forms"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-input-field>` web component is the form-field wrapper of the Magma Design System. It does not render an input itself; instead it decorates a slotted `<mds-input>` (or similar control) with a top label and a bottom message area, and reacts to the control's validation lifecycle. It plays the role the native `<label>` + helper-text grouping plays around an `<input>`.\n\n#### Semantic Behavior\n\n- **Compound parent**: The interactive control is supplied through the default slot; the field is not used standalone. Validation is wired to the first slotted element; with an empty slot the field only logs a console warning at load.\n- **Form association**: The field participates in the surrounding `<form>` through the control it wraps, requiring no extra wiring.\n- **Validation-driven state**: It listens for the slotted control's `mdsInputValidation` event. When the control reports errors it switches `variant` to `'error'` and shows the joined error strings in `message`; otherwise it sets `variant` to `'success'` and clears `message`.\n- **Message rendering**: `message` is split on `;` and each segment is rendered as a separate caption line, so multiple validation messages stack vertically.\n\n#### Properties & Visual Configurations\n\n- **`message`** is the helper/error text shown under the control. It is author-set initially but is overwritten by the validation cycle once the slotted control emits validation (replaced by the errors, or cleared when there are none), so a manually set message persists only until the first validation.\n- **`icon`** draws an icon before the label, in the emphasis colour of the `variant` (muted while the variant is `'primary'`): the state the message tells, seen at a glance, such as a verdict on the value the field holds. It takes the name of an icon or its SVG, as `mds-icon`. The icon is decorative and hidden from assistive technologies: the message says the state in words, and the label alone names the control. Without `icon` the label stands alone, as it always did.\n- **`short`** states that the answer of the field is short: a house number, a postcode, a tax code, a date. It says the meaning, and the `field-group` utility of the styles package lays it out: from a column of `28rem` a short field takes half of it and two in a row share it, under it each takes the whole column (`widths/field` of the design language). Out of a `field-group` the field keeps its width.\n- **`variant`** drives the field's status colouring. It is not the full theme ladder: the allowed set is the input-specific variant ladder (`'ai'`, `'primary'`, plus the status values `'error'`, `'info'`, `'success'`, `'warning'`), drawn from the families in [`agents/variants.md`](../../../../agents/variants.md). It defaults to `'primary'` and is normally managed automatically by validation rather than set by hand.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-input-field>` component, ordered from most common to most specialized. The examples assume a working knowledge of the variant / tone ladders documented in [`agents/variants.md`](../../../../agents/variants.md) and the shared component rules in [`agents/conventions.md`](../../../../agents/conventions.md).\n\n#### Basic Labeled Input\n\nThe canonical form. Wrap [`mds-input`](../mds-input/AGENTS.md) in `<mds-input-field>` and set `label` for the visible field caption. The `<mds-input>` must be the first slotted element: the field wires validation to it, and with an empty slot it only logs a console warning.\n\n```html\n<mds-input-field label=\"Nome e cognome\">\n  <mds-input name=\"fullName\" placeholder=\"Es: Mario Rossi\"></mds-input>\n</mds-input-field>\n```\n\n#### Input with a Static Helper Message\n\nSet `message` to show a persistent hint below the control. The message disappears once the slotted input emits its first `mdsInputValidation` event, so use this only for pre-validation guidance.\n\n```html\n<mds-input-field label=\"Codice fiscale\" message=\"16 caratteri alfanumerici\">\n  <mds-input name=\"cf\" type=\"cf\" placeholder=\"Es: MRCRSS83B21D704L\"></mds-input>\n</mds-input-field>\n```\n\n#### A Verdict with Its Icon\n\nWhen the page judges the value of the field (a choice that holds or not, a check the value passes), set `variant` to the verdict, say it in `message` and give `icon` the mark of the verdict: it stands before the label, in the colour of the variant. The words stay in the message; the icon only lets the eye find the state.\n\n```html\n<mds-input-field\n  label=\"Spazio colore\"\n  variant=\"warning\"\n  icon=\"mi/baseline/warning\"\n  message=\"La tonalità ruota di 25 gradi nei gradini scuri;OKLAB tiene meglio questo colore\"\n>\n  <mds-input-select>\n    <option value=\"OKLCH\" selected>OKLCH</option>\n    <option value=\"OKLAB\">OKLAB</option>\n  </mds-input-select>\n</mds-input-field>\n```\n\n#### Validation-Driven State\n\nWhen `<mds-input>` carries validation rules (e.g. `required`, `type=\"cf\"`, or `pattern`), `<mds-input-field>` listens for `mdsInputValidation` and automatically sets `variant` to `'error'` (showing joined error messages) or `'success'` (clearing the message). No event wiring is needed - just add the validation attributes to the slotted input.\n\n```html\n<mds-input-field label=\"Indirizzo email\">\n  <mds-input name=\"email\" type=\"email\" required placeholder=\"Es: mario@esempio.it\"></mds-input>\n</mds-input-field>\n```\n\n#### Explicit Variant for Initial Status\n\nIf the field must start in a known non-default state - for example a server-side validation result rendered on page load - set `variant` directly. The validation cycle overwrites it at the first `mdsInputValidation` of the slotted input, which an `<mds-input>` emits on blur only when it has validation rules.\n\n```html\n<!-- Server returned an error before page load -->\n<mds-input-field\n  label=\"Username\"\n  variant=\"error\"\n  message=\"Username gia in uso\"\n>\n  <mds-input name=\"username\" value=\"mario.rossi\"></mds-input>\n</mds-input-field>\n```\n\n#### Field with an Action Button\n\nThe default slot accepts multiple elements. The first child grows to fill the available width; subsequent children shrink to their natural size. Use this to pair an input with a companion [`mds-button`](../mds-button/AGENTS.md).\n\n```html\n<mds-input-field label=\"Cerca per nome\">\n  <mds-input name=\"query\" placeholder=\"Es: Mario Rossi\"></mds-input>\n  <mds-button icon=\"mi/baseline/search\" size=\"lg\" aria-label=\"Cerca\"></mds-button>\n</mds-input-field>\n```\n\n#### Inside a Form\n\nThe slotted `<mds-input>` is itself form-associated and submits under its own `name`. Place the field inside a `<form>` with a submit button; the field requires no extra wiring.\n\n```html\n<form action=\"/registrazione\" method=\"post\">\n  <mds-input-field label=\"Nome\">\n    <mds-input name=\"firstName\" required placeholder=\"Es: Mario\"></mds-input>\n  </mds-input-field>\n\n  <mds-input-field label=\"Cognome\">\n    <mds-input name=\"lastName\" required placeholder=\"Es: Rossi\"></mds-input>\n  </mds-input-field>\n\n  <mds-button type=\"submit\" label=\"Registrati\" variant=\"primary\" tone=\"strong\"></mds-button>\n</form>\n```\n\n#### Short Answers in a Group of Fields\n\nSet `short` on a field whose answer is short (a house number, a postcode, a tax code, a date), and put the fields of one subject in a `fieldset` with the `field-group` utility of the styles package. A short field takes half the column and two in a row share it, in reading order: number and postcode, tax code and date of birth. Every other field takes the whole column, and under a column of `28rem` the halves take it too. The group reads its direct children: a framework component that wraps the field carries `short` on its own host.\n\n```html\n<form class=\"max-w-form\">\n  <fieldset class=\"field-group\">\n    <legend>Residenza</legend>\n    <mds-input-field label=\"Via\">\n      <mds-input name=\"street\"></mds-input>\n    </mds-input-field>\n    <mds-input-field label=\"Numero civico\" short>\n      <mds-input name=\"number\"></mds-input>\n    </mds-input-field>\n    <mds-input-field label=\"CAP\" short>\n      <mds-input name=\"postcode\"></mds-input>\n    </mds-input-field>\n  </fieldset>\n</form>\n```\n\n#### Styling Customization\n\nAdjust the message area colors through the two documented `--mds-input-field-*` CSS custom properties. Use the semantic color roles via `rgb(var(--magma-<role>))` ([`agents/color.md`](../../../../agents/color.md)) so dark mode and high-contrast modes keep working.\n\n```css\n.field-highlight mds-input-field {\n  --mds-input-field-message-color: rgb(var(--magma-accent-fg));\n  --mds-input-field-message-background: rgb(var(--magma-accent-surface));\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-input-field>`. 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 It Without a Slotted Input\n\n`<mds-input-field>` requires a slotted input element. With an empty slot it only logs a console warning at load and has no control to label or validate. Always slot an [`mds-input`](../mds-input/AGENTS.md) as the first child.\n\n```html\n<!-- INCORRECT -->\n<mds-input-field label=\"Nome\"></mds-input-field>\n\n<!-- CORRECT -->\n<mds-input-field label=\"Nome\">\n  <mds-input name=\"firstName\" placeholder=\"Es: Mario\"></mds-input>\n</mds-input-field>\n```\n\n#### Do Not Use a Native `<input>` in the Slot\n\nThe component binds to `mdsInputValidation`, which only the Magma inputs (`<mds-input>`, `<mds-input-date>`) emit. Slotting a raw `<input>` skips the validation lifecycle entirely - the field will never switch to `error` or `success`.\n\n```html\n<!-- INCORRECT -->\n<mds-input-field label=\"Email\">\n  <input type=\"email\" name=\"email\" required>\n</mds-input-field>\n\n<!-- CORRECT -->\n<mds-input-field label=\"Email\">\n  <mds-input type=\"email\" name=\"email\" required></mds-input>\n</mds-input-field>\n```\n\n#### Do Not Manage `variant` and `message` Manually During Validation\n\n`variant` and `message` are mutable and will be overwritten by the validation cycle the moment the slotted control emits `mdsInputValidation`. Trying to manage them via script in parallel leads to race conditions. Set validation attributes on `<mds-input>` and let the field drive state automatically.\n\n```html\n<!-- INCORRECT -->\n<mds-input-field id=\"nameField\" label=\"Nome\">\n  <mds-input name=\"firstName\" required></mds-input>\n</mds-input-field>\n<script>\n  document.getElementById('nameField').variant = 'error';\n  document.getElementById('nameField').message = 'Campo obbligatorio';\n</script>\n\n<!-- CORRECT -->\n<mds-input-field label=\"Nome\">\n  <mds-input name=\"firstName\" required></mds-input>\n</mds-input-field>\n```\n\n#### Do Not Listen for Native `change` or `input` Events to Detect Validation\n\nNative DOM events (`change`, `input`) do not carry validation state and may not bubble out of shadow DOM as expected. Listen for the documented `mdsInputValidation` event on the slotted `<mds-input>` if you need to react to validation results in your own code.\n\n```html\n<!-- INCORRECT -->\n<mds-input-field label=\"Codice fiscale\">\n  <mds-input id=\"cfInput\" name=\"cf\" type=\"cf\" required></mds-input>\n</mds-input-field>\n<script>\n  document.getElementById('cfInput').addEventListener('change', handleChange);\n</script>\n\n<!-- CORRECT -->\n<mds-input-field label=\"Codice fiscale\">\n  <mds-input id=\"cfInput\" name=\"cf\" type=\"cf\" required></mds-input>\n</mds-input-field>\n<script>\n  document.getElementById('cfInput').addEventListener('mdsInputValidation', handleValidation);\n</script>\n```\n\n#### Do Not Apply an Invalid `variant` Value\n\n`<mds-input-field>` uses `ThemeInputVariantType`, which only accepts `'ai'`, `'primary'`, `'error'`, `'info'`, `'success'`, and `'warning'`. Values from the broader variant ladder (e.g. `'secondary'`, `'dark'`) silently fall back to the default and produce no coloring change.\n\n```html\n<!-- INCORRECT (variant from the full theme ladder) -->\n<mds-input-field label=\"Stato\" variant=\"secondary\" message=\"Valore non valido\">\n  <mds-input name=\"stato\"></mds-input>\n</mds-input-field>\n\n<!-- CORRECT -->\n<mds-input-field label=\"Stato\" variant=\"warning\" message=\"Valore non valido\">\n  <mds-input name=\"stato\"></mds-input>\n</mds-input-field>\n```\n\n#### Do Not Narrow a Short Field by Hand\n\nA width written on the field, or a wrapper per pair, gives every field an edge of its own and copies the threshold under which the halves take the whole column. `short` in a `field-group` keeps two widths, the whole column and half of it, and the threshold in one place.\n\n```html\n<!-- INCORRECT -->\n<div class=\"flex flex-wrap gap-between-fields\">\n  <mds-input-field label=\"Numero civico\" class=\"w-32\">\n    <mds-input name=\"number\"></mds-input>\n  </mds-input-field>\n  <mds-input-field label=\"CAP\" class=\"w-1/2\">\n    <mds-input name=\"postcode\"></mds-input>\n  </mds-input-field>\n</div>\n\n<!-- CORRECT -->\n<fieldset class=\"field-group\">\n  <legend>Residenza</legend>\n  <mds-input-field label=\"Numero civico\" short>\n    <mds-input name=\"number\"></mds-input>\n  </mds-input-field>\n  <mds-input-field label=\"CAP\" short>\n    <mds-input name=\"postcode\"></mds-input>\n  </mds-input-field>\n</fieldset>\n```\n\n#### Do Not Tell the State with the Icon Alone\n\n`icon` is decorative: hidden from assistive technologies, it only lets the eye find a state the message says in words. A field that shows a warning icon with no message tells a screen reader nothing; a symbol written into `label` instead reaches the name of the control, read before its label.\n\n```html\n<!-- INCORRECT -->\n<mds-input-field label=\"Spazio colore\" variant=\"warning\" icon=\"mi/baseline/warning\">\n  <mds-input-select>...</mds-input-select>\n</mds-input-field>\n\n<!-- CORRECT -->\n<mds-input-field\n  label=\"Spazio colore\"\n  variant=\"warning\"\n  icon=\"mi/baseline/warning\"\n  message=\"La tonalità ruota di 25 gradi nei gradini scuri\"\n>\n  <mds-input-select>...</mds-input-select>\n</mds-input-field>\n```\n\n#### Do Not Pierce the Shadow DOM to Style the Message Area\n\nThe only supported customization surface is `--mds-input-field-message-color` and `--mds-input-field-message-background`, plus the `content` shadow part. Targeting internal elements via `>>>` or undocumented class names couples your code to the implementation and will break on minor releases.\n\n```css\n/* INCORRECT */\nmds-input-field >>> .message {\n  color: red;\n}\n\n/* CORRECT */\nmds-input-field {\n  --mds-input-field-message-color: rgb(var(--magma-danger-text-muted));\n  --mds-input-field-message-background: rgb(var(--magma-danger-wash-base));\n}\n```\n"
      },
      "props": [
        {
          "name": "icon",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "icon",
          "reflectToAttr": false,
          "docs": "An icon before the label, in the colour of the variant: the state the message tells, seen at a\nglance (a verdict on the value, a check passed). Decorative: the message says the state in\nwords, and the label stays the name of the control",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "label",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": true,
          "attr": "label",
          "reflectToAttr": false,
          "docs": "Display a text on the top of the input text field",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "message",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": true,
          "attr": "message",
          "reflectToAttr": false,
          "docs": "Display a message at the bottom of the input text field",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "short",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "short",
          "reflectToAttr": true,
          "docs": "States that the answer of the field is short, such as a house number, a postcode, a tax code\nor a date: in a `field-group` the field takes half the column, and two short fields in a row\nshare it (#1189, widths/field). The group lays it out; on its own the field keeps its width",
          "docsTags": [
            {
              "name": "default",
              "text": "false"
            }
          ],
          "default": "false",
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "variant",
          "type": "\"ai\" | \"error\" | \"info\" | \"primary\" | \"success\" | \"warning\" | undefined",
          "complexType": {
            "original": "ThemeInputVariantType",
            "resolved": "\"ai\" | \"error\" | \"info\" | \"primary\" | \"success\" | \"warning\" | undefined",
            "references": {
              "ThemeInputVariantType": {
                "location": "import",
                "path": "@type/variant",
                "id": "src/type/variant.ts::ThemeInputVariantType",
                "referenceLocation": "ThemeInputVariantType"
              }
            }
          },
          "mutable": true,
          "attr": "variant",
          "reflectToAttr": true,
          "docs": "Display the variant of a message at the bottom of the input text field",
          "docsTags": [
            {
              "name": "default",
              "text": "'primary'"
            }
          ],
          "default": "'primary'",
          "values": [
            {
              "value": "ai",
              "type": "string"
            },
            {
              "value": "error",
              "type": "string"
            },
            {
              "value": "info",
              "type": "string"
            },
            {
              "value": "primary",
              "type": "string"
            },
            {
              "value": "success",
              "type": "string"
            },
            {
              "value": "warning",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [],
      "listeners": [],
      "styles": [
        {
          "name": "--mds-input-field-message-background",
          "annotation": "prop",
          "docs": "Sets the message background color of the component, will be visible only if there is a text defined by `message` component attribute",
          "visibility": "public"
        },
        {
          "name": "--mds-input-field-message-color",
          "annotation": "prop",
          "docs": "Sets the message text color of the component",
          "visibility": "public"
        }
      ],
      "slots": [
        {
          "name": "",
          "docs": "Add one `mds-input` or `mds-input-date`: the field names it with `label` and shows its\nvalidation errors in `message`. Another control, a native `<input>` among them, gets the name\nbut no validation messages."
        }
      ],
      "parts": [
        {
          "name": "content",
          "docs": "The wrapper of the default slot, above the message"
        }
      ],
      "states": [],
      "dependents": [],
      "dependencies": [
        "mds-icon",
        "mds-text"
      ],
      "dependencyGraph": {
        "mds-input-field": [
          "mds-icon",
          "mds-text"
        ]
      },
      "storybook": "form-input-field--docs"
    }
  ]
}
