{
  "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-filter-item/mds-filter-item.tsx",
      "encapsulation": "shadow",
      "tag": "mds-filter-item",
      "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": "parent",
          "text": "mds-filter"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-filter-item>` web component is a single selectable option inside the [`<mds-filter>`](../mds-filter/AGENTS.md) container of the Magma Design System. It renders as a toggle button (icon, label, and an optional count badge) and acts as the toggleable unit that drives the parent's filter selection - it has no standalone HTML primitive equivalent.\n\n#### Semantic Behavior\n\n- **Compound child only**: `<mds-filter-item>` must be a direct slot child of `<mds-filter>`; it is not used standalone and should not be mixed with other child types.\n- **Self-toggling + event**: Clicking (or activating via the keyboard) flips `selected` and emits `mdsFilterItemSelect` with `{ id, selected }`. The `id` is the one set in the markup; an item without one gets `item-<index>` from the parent on load. The parent enforces single vs. multiple selection and re-emits `mdsFilterChange` with the aggregated value list.\n- **State owned with the parent**: `selected` doubles as a styling hook and as the flag the parent reads/writes - in single-select mode the parent clears the other items' selection, and on reset it clears the whole group. The parent also follows a `selected` set by the application, without emitting `mdsFilterChange`.\n- **Toggle button**: The host is a `button` whose `aria-pressed` follows `selected`. Its name is the `label` followed by the `count` as a number of results in the page language (the `lang` of `<html>`): \"Nuove, 11 results\" in English, \"Nuove, 11 risultati\" in Italian. The name contains the text the item shows, the label and the count as separate words, so a speech-input user can say what they see (WCAG 2.5.3, Label in Name). An `aria-label` written on the host by the author stays, as written: it must contain that text too, and follow the count when it changes.\n- **Keyboard activation**: Enter (and numpad Enter) and Space activate the item like a pointer click.\n- **Focus management**: The item is focusable unless `disabled`, in which case it drops out of the tab order.\n\n#### Properties & Visual Configurations\n\n- **`selected`**: The selection state of the item. Set it on initial markup to pre-select a filter, or at runtime from the application (a filter restored from the address, a clear button outside the bar): the parent follows, in single mode clearing the others.\n- **`value`**: The form/data value contributed to the parent's aggregated `mdsFilterChange` payload when the item is selected. Provide a meaningful value distinct from the human-readable `label`.\n- **`count`**: An optional badge showing how many results the filter would yield. Use it only when the count is meaningful to the user; omit it for purely categorical filters.\n- **`icon`**: Optional leading icon (an icon name string). Without a `label` the item is named after the last segment of the slug (`map` for `mi/baseline/map`); give it an `aria-label` of your own when the slug does not say what the filter does.\n- **`disabled`**: Blocks the item: it leaves the tab order, ignores clicks and keys, is announced as unavailable (`aria-disabled`) and is painted in the disabled text colour.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-filter-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 Filter Group\n\nThe canonical form. Place one or more `<mds-filter-item>` elements as direct children of `<mds-filter>`. Every item requires a `label` (the visible text) and a `value` (the machine-readable token emitted by the parent's `mdsFilterChange` event).\n\n```html\n<mds-filter label=\"Stato\">\n  <mds-filter-item label=\"Attivo\" value=\"active\"></mds-filter-item>\n  <mds-filter-item label=\"In attesa\" value=\"pending\"></mds-filter-item>\n  <mds-filter-item label=\"Archiviato\" value=\"archived\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Pre-selecting an Item on Load\n\nSet `selected` on an item in the initial markup to make it active before any user interaction. The parent reads `selected` on mount and reflects the aggregated state correctly.\n\n```html\n<mds-filter label=\"Categoria\">\n  <mds-filter-item label=\"Tutti\" value=\"all\" selected></mds-filter-item>\n  <mds-filter-item label=\"Notizie\" value=\"news\"></mds-filter-item>\n  <mds-filter-item label=\"Eventi\" value=\"events\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Count Badge\n\nPass a `count` string to show how many results each filter would yield. Use it when the number is meaningful to the user; omit it for purely categorical filters to keep the UI uncluttered.\n\n```html\n<mds-filter label=\"Priorita\">\n  <mds-filter-item label=\"Alta\" value=\"high\" count=\"12\"></mds-filter-item>\n  <mds-filter-item label=\"Media\" value=\"medium\" count=\"34\"></mds-filter-item>\n  <mds-filter-item label=\"Bassa\" value=\"low\" count=\"5\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Icon-Only Item\n\nOmit `label` and provide only `icon`. Without a label the item is named after the last segment of the icon slug (`grid view` for `mi/baseline/grid-view`); an `aria-label` of your own takes its place and stays. Use a recognizable icon so the purpose is clear without text, and give each item an `aria-label` when the slug does not say what it filters.\n\n```html\n<mds-filter label=\"Vista\">\n  <mds-filter-item aria-label=\"Griglia\" icon=\"mi/baseline/grid-view\" value=\"grid\"></mds-filter-item>\n  <mds-filter-item aria-label=\"Elenco\" icon=\"mi/baseline/view-list\" value=\"list\"></mds-filter-item>\n  <mds-filter-item aria-label=\"Mappa\" icon=\"mi/baseline/map\" value=\"map\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Item with Icon and Label\n\nCombine `icon` and `label` for a filter item that pairs a glyph with a text description.\n\n```html\n<mds-filter label=\"Tipo documento\">\n  <mds-filter-item icon=\"mi/baseline/picture-as-pdf\" label=\"PDF\" value=\"pdf\"></mds-filter-item>\n  <mds-filter-item icon=\"mi/baseline/image\" label=\"Immagini\" value=\"image\"></mds-filter-item>\n  <mds-filter-item icon=\"mi/baseline/video-library\" label=\"Video\" value=\"video\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Multiple Selection\n\nAdd `multiple` to `<mds-filter>` to allow several items to be selected at the same time. The parent aggregates the selected `value`s into a comma-separated string and emits it via `mdsFilterChange`.\n\n```html\n<mds-filter label=\"Settore\" multiple>\n  <mds-filter-item label=\"Sanita\" value=\"health\"></mds-filter-item>\n  <mds-filter-item label=\"Istruzione\" value=\"education\"></mds-filter-item>\n  <mds-filter-item label=\"Trasporti\" value=\"transport\"></mds-filter-item>\n  <mds-filter-item label=\"Ambiente\" value=\"environment\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Listening for Selection Events\n\nListen to `mdsFilterItemSelect` on a single item for per-item reactions, or to `mdsFilterChange` on the parent for the aggregated selection. The event detail for `mdsFilterItemSelect` is `{ id: string, selected: boolean }`.\n\n```html\n<mds-filter id=\"tipo-filter\" label=\"Tipo\">\n  <mds-filter-item label=\"Bozza\" value=\"draft\"></mds-filter-item>\n  <mds-filter-item label=\"Pubblicato\" value=\"published\"></mds-filter-item>\n</mds-filter>\n\n<script>\n  document.getElementById('tipo-filter').addEventListener('mdsFilterChange', (e) => {\n    console.log('Valori selezionati:', e.detail.value);\n  });\n</script>\n```\n\n#### Reset Affordance\n\nAdd `reset` to `<mds-filter>` to show an automatic reset button when at least one item is active. The button is rendered by the parent internally - no extra `<mds-filter-item>` is needed - and named in the page language (\"Clear filters\").\n\n```html\n<mds-filter label=\"Regione\" reset>\n  <mds-filter-item label=\"Nord\" value=\"north\"></mds-filter-item>\n  <mds-filter-item label=\"Centro\" value=\"center\"></mds-filter-item>\n  <mds-filter-item label=\"Sud\" value=\"south\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Styling the Count Badge\n\n`<mds-filter-item>` has no public CSS custom property and no shadow part: the count badge takes its colours from the item's `selected` state. To restyle the bar the items sit in, set the public `--mds-filter-*` properties on the parent `<mds-filter>`; use the semantic color roles via `rgb(var(--magma-<role>))`.\n\n```css\n.priority-filter mds-filter {\n  --mds-filter-items-background: rgb(var(--magma-wash-strong));\n  --mds-filter-items-background-active: rgb(var(--magma-accent-surface));\n}\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-filter-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 `<mds-filter-item>` Outside `<mds-filter>`\n\n`<mds-filter-item>` is a compound child component. Without its parent it has no selection management, no auto-scroll, and no `mdsFilterChange` aggregation. Always wrap it in `<mds-filter>`.\n\n```html\n<!-- INCORRECT -->\n<div class=\"my-filters\">\n  <mds-filter-item label=\"Attivo\" value=\"active\"></mds-filter-item>\n  <mds-filter-item label=\"Archiviato\" value=\"archived\"></mds-filter-item>\n</div>\n\n<!-- CORRECT -->\n<mds-filter label=\"Stato\">\n  <mds-filter-item label=\"Attivo\" value=\"active\"></mds-filter-item>\n  <mds-filter-item label=\"Archiviato\" value=\"archived\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Set `selected=\"false\"` to Deselect\n\n`selected` is a boolean prop: remove the attribute entirely to deselect, as for every boolean. The runtime happens to read the string `\"false\"` as `false`, but the attribute stays in the markup until the component renders, and HTML, `[selected]` selectors and `hasAttribute()` read a present attribute as set.\n\n```html\n<!-- INCORRECT -->\n<mds-filter label=\"Stato\">\n  <mds-filter-item label=\"Attivo\" value=\"active\" selected=\"false\"></mds-filter-item>\n</mds-filter>\n\n<!-- CORRECT -->\n<mds-filter label=\"Stato\">\n  <mds-filter-item label=\"Attivo\" value=\"active\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Omit `value`\n\n`value` is the machine-readable token the parent aggregates into `mdsFilterChange`. Without it the parent's event payload is empty or meaningless for consumers - always provide a distinct, meaningful value.\n\n```html\n<!-- INCORRECT -->\n<mds-filter label=\"Priorita\">\n  <mds-filter-item label=\"Alta\"></mds-filter-item>\n  <mds-filter-item label=\"Bassa\"></mds-filter-item>\n</mds-filter>\n\n<!-- CORRECT -->\n<mds-filter label=\"Priorita\">\n  <mds-filter-item label=\"Alta\" value=\"high\"></mds-filter-item>\n  <mds-filter-item label=\"Bassa\" value=\"low\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Leave the Count Out of an `aria-label` of Your Own\n\nThe item names itself after its label and its count. An `aria-label` written on the host replaces that name as it is, and the count the item shows is visible text too: a name without it fails WCAG 2.5.3 (Label in Name), and a speech-input user saying the number does not reach the item. Put the count in the name, or leave the name to the item.\n\n```html\n<!-- INCORRECT -->\n<mds-filter label=\"Vista\">\n  <mds-filter-item aria-label=\"Vista a griglia\" icon=\"mi/baseline/grid-view\" value=\"grid\" count=\"3\"></mds-filter-item>\n</mds-filter>\n\n<!-- CORRECT -->\n<mds-filter label=\"Vista\">\n  <mds-filter-item aria-label=\"Vista a griglia, 3 risultati\" icon=\"mi/baseline/grid-view\" value=\"grid\" count=\"3\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Slot Content Inside `<mds-filter-item>`\n\n`<mds-filter-item>` has no publicly documented default or named slots. Icon, label, and count are all props. Slotting arbitrary HTML has no effect - use the dedicated props instead.\n\n```html\n<!-- INCORRECT -->\n<mds-filter label=\"Formato\">\n  <mds-filter-item value=\"pdf\">\n    <mds-icon name=\"mi/baseline/picture-as-pdf\"></mds-icon>\n    PDF\n  </mds-filter-item>\n</mds-filter>\n\n<!-- CORRECT -->\n<mds-filter label=\"Formato\">\n  <mds-filter-item icon=\"mi/baseline/picture-as-pdf\" label=\"PDF\" value=\"pdf\"></mds-filter-item>\n</mds-filter>\n```\n\n#### Do Not Listen for Native `click` Instead of `mdsFilterItemSelect`\n\nThe component handles its own toggle internally and emits `mdsFilterItemSelect` when selection changes. A native `click` listener added before the component has loaded runs before the internal toggle (listeners run in the order they were added), so it reads the old `selected` state.\n\n```html\n<!-- INCORRECT -->\n<mds-filter label=\"Stato\">\n  <mds-filter-item label=\"Attivo\" value=\"active\"></mds-filter-item>\n</mds-filter>\n<script>\n  document.querySelector('mds-filter-item[value=\"active\"]').addEventListener('click', (e) => {\n    console.log('selected?', e.target.selected); // state not yet updated\n  });\n</script>\n\n<!-- CORRECT -->\n<mds-filter label=\"Stato\">\n  <mds-filter-item label=\"Attivo\" value=\"active\"></mds-filter-item>\n</mds-filter>\n<script>\n  document.querySelector('mds-filter-item[value=\"active\"]').addEventListener('mdsFilterItemSelect', (e) => {\n    console.log('selected:', e.detail.selected);\n  });\n</script>\n```\n\n#### Do Not Customize via Undocumented Shadow Parts or Internal Selectors\n\n`<mds-filter-item>` has no public CSS custom property and no shadow part: the count badge follows the `selected` state, and the bar is styled through the parent's public `--mds-filter-*` properties. Targeting shadow internals via `::part()`, `>>>`, or other selectors couples code to the implementation and will break on minor releases.\n\n```css\n/* INCORRECT */\nmds-filter-item >>> .count {\n  border-radius: 4px;\n}\nmds-filter-item::part(count) {\n  background: red;\n}\n\n/* CORRECT */\nmds-filter {\n  --mds-filter-items-background: rgb(var(--magma-wash-strong));\n  --mds-filter-items-background-active: rgb(var(--magma-accent-surface));\n}\n```\n"
      },
      "props": [
        {
          "name": "count",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "count",
          "reflectToAttr": true,
          "docs": "Shows the number of items will be filtered by the component, also read out after the label\nas a number of results",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "disabled",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "disabled",
          "reflectToAttr": true,
          "docs": "Sets if the component is disabled or not",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "icon",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "icon",
          "reflectToAttr": true,
          "docs": "Sets the icon of the filter item",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "label",
          "type": "string",
          "complexType": {
            "original": "string",
            "resolved": "string",
            "references": {}
          },
          "mutable": false,
          "attr": "label",
          "reflectToAttr": true,
          "docs": "Sets the label of the filter item",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "selected",
          "type": "boolean | undefined",
          "complexType": {
            "original": "boolean",
            "resolved": "boolean | undefined",
            "references": {}
          },
          "mutable": true,
          "attr": "selected",
          "reflectToAttr": true,
          "docs": "Sets the component to selected state",
          "docsTags": [],
          "values": [
            {
              "type": "boolean"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "value",
          "type": "string",
          "complexType": {
            "original": "string",
            "resolved": "string",
            "references": {}
          },
          "mutable": false,
          "attr": "value",
          "reflectToAttr": true,
          "docs": "Sets the value of the component to be used with forms",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            }
          ],
          "optional": false,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [
        {
          "event": "mdsFilterItemSelect",
          "detail": "MdsFilterItemEventDetail",
          "bubbles": true,
          "complexType": {
            "original": "MdsFilterItemEventDetail",
            "resolved": "MdsFilterItemEventDetail",
            "references": {
              "MdsFilterItemEventDetail": {
                "location": "import",
                "path": "./meta/event-detail",
                "id": "src/components/mds-filter-item/meta/event-detail.ts::MdsFilterItemEventDetail",
                "referenceLocation": "MdsFilterItemEventDetail"
              }
            }
          },
          "cancelable": true,
          "composed": true,
          "docs": "Emits when the element is active",
          "docsTags": []
        }
      ],
      "listeners": [],
      "styles": [
        {
          "name": "--mds-filter-item-count-background-default",
          "annotation": "prop",
          "docs": "Sets the default `background-color` of the count element",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-item-count-background-selected",
          "annotation": "prop",
          "docs": "Sets the `background-color` of the count element when it's selected",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-item-count-color-default",
          "annotation": "prop",
          "docs": "Sets the default text `color` of the count element",
          "visibility": "internal"
        },
        {
          "name": "--mds-filter-item-count-color-selected",
          "annotation": "prop",
          "docs": "Sets the `color` of the count element when it's selected",
          "visibility": "internal"
        }
      ],
      "slots": [],
      "parts": [],
      "states": [],
      "dependents": [
        "mds-filter"
      ],
      "dependencies": [
        "mds-icon",
        "mds-text"
      ],
      "dependencyGraph": {
        "mds-filter-item": [
          "mds-icon",
          "mds-text"
        ],
        "mds-filter": [
          "mds-filter-item"
        ]
      },
      "storybook": "ui-filter-filter-item--docs"
    }
  ]
}
