{
  "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-avatar/mds-avatar.tsx",
      "encapsulation": "shadow",
      "tag": "mds-avatar",
      "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": "part",
          "text": "icon - The selected icon of the avatar"
        },
        {
          "name": "part",
          "text": "wrapper - The wrapper which contains media displayed"
        },
        {
          "name": "part",
          "text": "media - The media displayed"
        },
        {
          "name": "category",
          "text": "data"
        }
      ],
      "usage": {
        "1. Description": "The `<mds-avatar>` web component renders a compact, circular representation of a user or entity in the Magma Design System. It resolves a single visual from whichever input is provided - a profile image, textual initials, a numeric overflow count, or an icon - and falls back to a generic person glyph when nothing usable is supplied.\n\n#### Semantic Behavior\n\n- **Content resolution**: Exactly one visual is shown at a time, picked in one order: `count`, then the `src` image, then `initials`, then `icon`, then the generic person fallback. A source hides the ones after it, so `initials` or `icon` next to `src` are the fallbacks of the image.\n- **Deterministic identity color**: When `initials` is set, the component derives the color from its characters, so the same person always maps to the same color and stays distinguishable from others. Any explicit `variant` is ignored in this case; `count` derives no color and keeps the `variant`.\n- **Image load fallback**: If the `src` image fails to load, the avatar shows the next source in the order: `initials`, then `icon`, then the generic person fallback icon. A new `src` is tried again.\n- **Auto-fitting initials**: Initials and count text scale to fit the avatar, so they stay legible across every size.\n- **Initials display**: The first two characters of `initials` are displayed as they are, uppercased, so pass the initials (`MR`), not the full name. Non-alphanumeric characters are stripped only to compute the color.\n\n#### Properties & Visual Configurations\n\nThe shared `variant` / `tone` ladders are defined in [`agents/variants.md`](../../../../agents/variants.md). Note that `tone` is limited to the minimal set (`'strong'` / `'weak'`), and any explicit `variant` is ignored whenever `initials` is present, since identity color takes precedence.\n\n#### Other behavioral props\n\n- **`src`** is the path to a profile image; prefer it when a real photo is available. Only `count` hides it; `initials` and `icon` set as well show when the image fails to load.\n- **`initials`** carries the textual stand-in for a user when no image exists; it drives the deterministic identity color.\n- **`count`** renders a `+N` overflow badge and is intended for stacked/grouped avatar scenarios rather than individual users.\n- **`icon`** is an SVG filename slug from the Magma icon library, used when the avatar represents a non-personal entity rather than a human.\n",
        "2. Examples": "Correct and idiomatic ways to use the `<mds-avatar>` 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#### Profile Image via `src`\n\nThe most common form: supply a URL and the component loads the image lazily. If the image fails to load the component falls back to `initials` (or `icon`) when set, else to the generic person glyph - no extra wiring needed.\n\n```html\n<!-- the initials show if the photo fails to load -->\n<mds-avatar src=\"https://example.com/foto-utente.jpg\" initials=\"MR\"></mds-avatar>\n```\n\n```html\n<mds-avatar src=\"https://example.com/foto-utente.jpg\"></mds-avatar>\n```\n\n#### Initials Fallback\n\nWhen no photo is available, provide the user's initials. The component displays the first two characters, uppercased, so pass the initials rather than the full name. It also derives a deterministic color from the characters (ignoring non-alphanumeric ones) so the same person always maps to the same hue.\n\n```html\n<mds-avatar initials=\"MR\"></mds-avatar>\n<!-- displayed as \"MR\" with a stable identity color -->\n\n<mds-avatar initials=\"ab\"></mds-avatar>\n<!-- displayed as \"AB\" -->\n```\n\n#### Manual Variant and Tone (no initials)\n\nWhen `initials` is not set, you can control the avatar background and icon color through `variant` and `tone`. Use this for non-personal entity avatars where identity color is not required.\n\n```html\n<!-- Primary brand color, filled -->\n<mds-avatar variant=\"primary\" tone=\"strong\" icon=\"mi/baseline/support-agent\"></mds-avatar>\n\n<!-- Success semantic, weak tint -->\n<mds-avatar variant=\"success\" tone=\"weak\"></mds-avatar>\n```\n\n#### Icon Avatar for Non-Personal Entities\n\nUse `icon` when the avatar represents a system, service, or non-human entity. Reference icons by their slug (no `.svg` extension). The generic person fallback is replaced by the provided icon.\n\n```html\n<mds-avatar icon=\"mi/baseline/business\" variant=\"primary\"></mds-avatar>\n<mds-avatar icon=\"mi/baseline/pets\" variant=\"info\"></mds-avatar>\n```\n\n#### Overflow Count in Stacked Groups\n\nUse `count` to render a \"+N\" overflow badge for the last slot in an avatar stack (e.g. \"3 more\"). The count display overrides every other source (`src`, `initials`, `icon`) and, unlike `initials`, derives no color: it keeps the `variant`. Use inside [`mds-avatar-stack`](../mds-avatar-stack/AGENTS.md) and [`mds-avatar-stack-item`](../mds-avatar-stack-item/AGENTS.md).\n\n```html\n<mds-avatar-stack>\n  <mds-avatar-stack-item src=\"https://example.com/foto-01.jpg\"></mds-avatar-stack-item>\n  <mds-avatar-stack-item src=\"https://example.com/foto-02.jpg\"></mds-avatar-stack-item>\n  <mds-avatar-stack-item count=\"3\"></mds-avatar-stack-item>\n</mds-avatar-stack>\n```\n\n#### Sizing via Utility Classes\n\n`<mds-avatar>` does not expose a `size` prop - its size is controlled by the host element's `width` (the component uses `aspect-ratio: 1/1` internally). Apply a Magma spacing utility class on the host.\n\n```html\n<!-- Small avatar -->\n<mds-avatar src=\"https://example.com/foto.jpg\" class=\"w-600\"></mds-avatar>\n\n<!-- Default / medium avatar -->\n<mds-avatar src=\"https://example.com/foto.jpg\" class=\"w-1200\"></mds-avatar>\n\n<!-- Large avatar -->\n<mds-avatar src=\"https://example.com/foto.jpg\" class=\"w-2400\"></mds-avatar>\n```\n\n#### Styling Customization\n\nStyle the avatar only through its public `--mds-avatar-*` CSS custom properties. Use semantic color roles wrapped in `rgb(var(--magma-<role>))` so dark mode and high-contrast modes work correctly.\n\n```css\n.profilo-utente mds-avatar {\n  --mds-avatar-background-color: rgb(var(--magma-accent-emphasis));\n  --mds-avatar-color: rgb(var(--magma-accent-on-emphasis));\n  --mds-avatar-radius: var(--magma-radius-md);\n\n  corner-shape: var(--magma-corner-shape);\n}\n```\n\n#### Square Avatar via `--mds-avatar-radius`\n\nThe default shape is fully circular. Override the CSS custom property to get a square or rounded-square avatar - for example when representing a product or brand logo rather than a person.\n\nThe circle stays out of the corner axis, so the host declares no corner shape. A step of the `--magma-radius-*` scale is tuned for the shape of the axis: give the host `corner-shape: var(--magma-corner-shape)` with it, and the inner image and initials follow.\n\n```css\n.logo-azienda mds-avatar {\n  --mds-avatar-radius: var(--magma-radius-md);\n\n  corner-shape: var(--magma-corner-shape);\n}\n```\n\n```html\n<mds-avatar\n  class=\"logo-azienda w-1600\"\n  src=\"https://example.com/logo-azienda.png\"\n></mds-avatar>\n```\n",
        "3. Mistakes": "Common incorrect uses of `<mds-avatar>`. 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 Set `variant` When `initials` Is Present\n\nThe component derives the background color deterministically from the characters when `initials` is set, and silently overrides any explicit `variant`. Setting `variant` alongside these props is a no-op and misleads readers of the markup.\n\n```html\n<!-- INCORRECT -->\n<mds-avatar initials=\"MR\" variant=\"error\"></mds-avatar>\n\n<!-- CORRECT -->\n<mds-avatar initials=\"MR\"></mds-avatar>\n```\n\n#### Do Not Use `count` for Individual Users\n\n`count` is designed for overflow badges in stacked avatar groups (\"+3 more\"). Using it to represent a single user's identity (e.g. an ID number) produces a \"+N\" label, which is semantically wrong. Use `initials` for individual users.\n\n```html\n<!-- INCORRECT -->\n<mds-avatar count=\"42\"></mds-avatar>\n\n<!-- CORRECT - use initials for individual users -->\n<mds-avatar initials=\"GV\"></mds-avatar>\n```\n\n#### Do Not Override Size with Inline `width` / `height` Styles\n\n`<mds-avatar>` keeps a 1:1 aspect ratio internally. Forcing `width` or `height` via inline styles or arbitrary CSS bypasses the design token grid and can distort the shape. Use a Magma spacing utility class on the host element instead.\n\n```html\n<!-- INCORRECT -->\n<mds-avatar src=\"https://example.com/foto.jpg\" style=\"width: 73px; height: 73px;\"></mds-avatar>\n\n<!-- CORRECT -->\n<mds-avatar src=\"https://example.com/foto.jpg\" class=\"w-1600\"></mds-avatar>\n```\n\n#### Do Not Slot `<img>` to Supply a Profile Photo\n\n`<mds-avatar>` has no slots - it is a self-contained shadow component. Putting a raw `<img>` inside it will have no effect; the component will ignore it and show the fallback person glyph. Use the `src` prop instead.\n\n```html\n<!-- INCORRECT -->\n<mds-avatar>\n  <img src=\"https://example.com/foto.jpg\" alt=\"Mario Bianchi\" />\n</mds-avatar>\n\n<!-- CORRECT -->\n<mds-avatar src=\"https://example.com/foto.jpg\"></mds-avatar>\n```\n\n#### Do Not Pierce Shadow DOM to Change Internal Colors\n\nThe supported customization surface is the three public `--mds-avatar-*` CSS custom properties and, for a deep customisation, the documented parts `wrapper`, `media` and `icon`. Using undocumented part names, `>>>`, or internal class names to target internals couples your code to the Shadow DOM implementation and breaks on minor releases.\n\n```css\n/* INCORRECT */\nmds-avatar::part(initials) {\n  background-color: hotpink;\n}\nmds-avatar >>> .initials-text {\n  color: white;\n}\n\n/* CORRECT */\nmds-avatar {\n  --mds-avatar-background-color: rgb(var(--magma-accent-emphasis));\n  --mds-avatar-color: rgb(var(--magma-accent-on-emphasis));\n}\n```\n\n#### Do Not Use a Raw `<img>` or `<div>` as an Avatar\n\nWhen an avatar-style UI element is needed, reach for `<mds-avatar>` rather than hand-rolling a circular `<img>` or `<div>` with CSS. The component handles lazy loading, load errors, initials fallback, pending state, dark mode, and high-contrast mode automatically.\n\n```html\n<!-- INCORRECT -->\n<img\n  src=\"https://example.com/foto.jpg\"\n  alt=\"Foto di Luca\"\n  style=\"border-radius: 50%; width: 48px; height: 48px;\"\n/>\n\n<!-- CORRECT -->\n<mds-avatar src=\"https://example.com/foto.jpg\" class=\"w-1200\"></mds-avatar>\n```\n"
      },
      "props": [
        {
          "name": "count",
          "type": "number | undefined",
          "complexType": {
            "original": "number",
            "resolved": "number | undefined",
            "references": {}
          },
          "mutable": true,
          "attr": "count",
          "reflectToAttr": true,
          "docs": "The user's inizials displayed if there's no image available, initials will override tone and variant senttings to keep user recognizable from others",
          "docsTags": [],
          "values": [
            {
              "type": "number"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "icon",
          "type": "string | undefined",
          "complexType": {
            "original": "string | undefined",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "icon",
          "reflectToAttr": true,
          "docs": "Specifies the path to the icon",
          "docsTags": [
            {
              "name": "see",
              "text": "https://magma.maggiolicloud.it/storybook/?path=/story/design-icon--default"
            }
          ],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "initials",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": true,
          "attr": "initials",
          "reflectToAttr": true,
          "docs": "The user's inizials displayed if there's no image available, initials will override tone and variant senttings to keep user recognizable from others",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "src",
          "type": "string | undefined",
          "complexType": {
            "original": "string",
            "resolved": "string | undefined",
            "references": {}
          },
          "mutable": false,
          "attr": "src",
          "reflectToAttr": true,
          "docs": "Specifies the path to the image",
          "docsTags": [],
          "values": [
            {
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "tone",
          "type": "\"strong\" | \"weak\" | undefined",
          "complexType": {
            "original": "ToneMinimalVariantType",
            "resolved": "\"strong\" | \"weak\" | undefined",
            "references": {
              "ToneMinimalVariantType": {
                "location": "import",
                "path": "@type/tone",
                "id": "src/type/tone.ts::ToneMinimalVariantType",
                "referenceLocation": "ToneMinimalVariantType"
              }
            }
          },
          "mutable": false,
          "attr": "tone",
          "reflectToAttr": true,
          "docs": "Specifies the color tone of the component",
          "docsTags": [],
          "values": [
            {
              "value": "strong",
              "type": "string"
            },
            {
              "value": "weak",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        },
        {
          "name": "variant",
          "type": "\"amaranth\" | \"aqua\" | \"blue\" | \"error\" | \"green\" | \"info\" | \"lime\" | \"orange\" | \"orchid\" | \"primary\" | \"purple\" | \"red\" | \"sky\" | \"success\" | \"violet\" | \"warning\" | \"yellow\" | undefined",
          "complexType": {
            "original": "ThemeFullVariantAvatarType",
            "resolved": "\"amaranth\" | \"aqua\" | \"blue\" | \"error\" | \"green\" | \"info\" | \"lime\" | \"orange\" | \"orchid\" | \"primary\" | \"purple\" | \"red\" | \"sky\" | \"success\" | \"violet\" | \"warning\" | \"yellow\" | undefined",
            "references": {
              "ThemeFullVariantAvatarType": {
                "location": "import",
                "path": "@type/variant",
                "id": "src/type/variant.ts::ThemeFullVariantAvatarType",
                "referenceLocation": "ThemeFullVariantAvatarType"
              }
            }
          },
          "mutable": true,
          "attr": "variant",
          "reflectToAttr": true,
          "docs": "Specifies the color variant of the component",
          "docsTags": [],
          "values": [
            {
              "value": "amaranth",
              "type": "string"
            },
            {
              "value": "aqua",
              "type": "string"
            },
            {
              "value": "blue",
              "type": "string"
            },
            {
              "value": "error",
              "type": "string"
            },
            {
              "value": "green",
              "type": "string"
            },
            {
              "value": "info",
              "type": "string"
            },
            {
              "value": "lime",
              "type": "string"
            },
            {
              "value": "orange",
              "type": "string"
            },
            {
              "value": "orchid",
              "type": "string"
            },
            {
              "value": "primary",
              "type": "string"
            },
            {
              "value": "purple",
              "type": "string"
            },
            {
              "value": "red",
              "type": "string"
            },
            {
              "value": "sky",
              "type": "string"
            },
            {
              "value": "success",
              "type": "string"
            },
            {
              "value": "violet",
              "type": "string"
            },
            {
              "value": "warning",
              "type": "string"
            },
            {
              "value": "yellow",
              "type": "string"
            },
            {
              "type": "undefined"
            }
          ],
          "optional": true,
          "required": false,
          "getter": false,
          "setter": false
        }
      ],
      "methods": [],
      "events": [],
      "listeners": [],
      "styles": [
        {
          "name": "--mds-avatar-background-color",
          "annotation": "prop",
          "docs": "The background-color of the component",
          "visibility": "public"
        },
        {
          "name": "--mds-avatar-background-color-pending",
          "annotation": "prop",
          "docs": "The background-color when an image is loading",
          "visibility": "internal"
        },
        {
          "name": "--mds-avatar-color",
          "annotation": "prop",
          "docs": "The color of the placeholder icon",
          "visibility": "public"
        },
        {
          "name": "--mds-avatar-initials-padding",
          "annotation": "prop",
          "docs": "Sets the padding of the initials inside the avatar",
          "visibility": "internal"
        },
        {
          "name": "--mds-avatar-radius",
          "annotation": "prop",
          "docs": "The border-radius of the element",
          "visibility": "public"
        }
      ],
      "slots": [],
      "parts": [
        {
          "name": "icon",
          "docs": "The selected icon of the avatar"
        },
        {
          "name": "media",
          "docs": "The media displayed"
        },
        {
          "name": "wrapper",
          "docs": "The wrapper which contains media displayed"
        }
      ],
      "states": [],
      "dependents": [
        "mds-avatar-stack-item",
        "mds-entity",
        "mds-push-notification-item"
      ],
      "dependencies": [
        "mds-img",
        "mds-icon"
      ],
      "dependencyGraph": {
        "mds-avatar": [
          "mds-img",
          "mds-icon"
        ],
        "mds-img": [
          "mds-icon",
          "mds-text",
          "mds-button"
        ],
        "mds-button": [
          "mds-icon",
          "mds-spinner",
          "mds-text"
        ],
        "mds-avatar-stack-item": [
          "mds-avatar"
        ],
        "mds-entity": [
          "mds-avatar"
        ],
        "mds-push-notification-item": [
          "mds-avatar"
        ]
      },
      "storybook": "ui-avatar--docs"
    }
  ]
}
