<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-kpi-item/usage/ in the magma monorepo.
-->

# mds-kpi-item - mistakes

> The API of this component: [`AGENTS.md`](AGENTS.md).

Common incorrect uses of `<mds-kpi-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.

#### Do Not Use `mds-kpi-item` Outside `mds-kpi`

`<mds-kpi-item>` is a compound child designed to be a direct slot child of [`<mds-kpi>`](../mds-kpi/AGENTS.md). Using it standalone strips the list semantics that `<mds-kpi>` provides and breaks the expected visual layout.

```html
<!-- INCORRECT -->
<mds-kpi-item label="1.240" description="Pratiche elaborate"></mds-kpi-item>

<!-- CORRECT -->
<mds-kpi>
  <mds-kpi-item label="1.240" description="Pratiche elaborate"></mds-kpi-item>
</mds-kpi>
```

#### Do Not Slot HTML Content for the Label or Description

`<mds-kpi-item>` has no default slot - all text content is driven by the `label` and `description` props. Slotting child nodes produces no output because the component renders nothing from its slot.

```html
<!-- INCORRECT -->
<mds-kpi>
  <mds-kpi-item>
    <span>1.240</span>
    <small>Pratiche elaborate</small>
  </mds-kpi-item>
</mds-kpi>

<!-- CORRECT -->
<mds-kpi>
  <mds-kpi-item label="1.240" description="Pratiche elaborate"></mds-kpi-item>
</mds-kpi>
```

#### Do Not Slot `<mds-icon>` to Add an Icon

The `icon` prop passes the slug to the internal `<mds-icon>` instance. Slotting an `<mds-icon>` directly has no effect because the component has no named slot for icons.

```html
<!-- INCORRECT -->
<mds-kpi>
  <mds-kpi-item label="98%" description="Soddisfazione clienti">
    <mds-icon name="mi/baseline/thumb-up"></mds-icon>
  </mds-kpi-item>
</mds-kpi>

<!-- CORRECT -->
<mds-kpi>
  <mds-kpi-item
    label="98%"
    description="Soddisfazione clienti"
    icon="mi/baseline/thumb-up"
  ></mds-kpi-item>
</mds-kpi>
```

#### Do Not Set `threshold="0"` to Disable Animation - Omit It

`threshold` defaults to `0`, so setting it explicitly to `"0"` is a no-op. More importantly, `threshold="false"` or `threshold="none"` is parsed to `NaN`, which the IntersectionObserver rejects with an error at runtime.

```html
<!-- INCORRECT -->
<mds-kpi-item label="3.500" description="Utenti" threshold="false"></mds-kpi-item>
<mds-kpi-item label="3.500" description="Utenti" threshold="none"></mds-kpi-item>

<!-- CORRECT - omit threshold entirely for no animation (defaults to 0) -->
<mds-kpi-item label="3.500" description="Utenti"></mds-kpi-item>
```

#### Do Not Pierce Shadow DOM to Style Internal Elements

The supported customization surface is the three documented shadow parts (`icon-container`, `icon`, `content`), plus the public `--mds-kpi-text-animation-*` properties of the parent `<mds-kpi>`. Reaching inside the shadow DOM via `>>>` or undocumented class names couples your code to the implementation and will break on minor releases.

```css
/* INCORRECT */
mds-kpi-item >>> .info {
  background: white;
}
mds-kpi-item >>> .value {
  font-size: 3rem;
}

/* CORRECT */
mds-kpi-item::part(content) {
  background-color: rgb(var(--magma-surface-overlay));
  padding: calc(var(--spacing) * 600);
}
```

#### Do Not Leave Icon-Only Items Without an Accessible Name

When both `label` and `description` are omitted the item has no accessible name at all. Supply an explicit `aria-label` on the host when the item carries no text props (the component keeps it at first render, but writes its own name back at its next re-render).

```html
<!-- INCORRECT -->
<mds-kpi>
  <mds-kpi-item icon="mi/baseline/star"></mds-kpi-item>
</mds-kpi>

<!-- CORRECT -->
<mds-kpi>
  <mds-kpi-item
    icon="mi/baseline/star"
    aria-label="Valutazione eccellente"
  ></mds-kpi-item>
</mds-kpi>
```
