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

# mds-notification - mistakes

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

Common incorrect uses of `<mds-notification>`. 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 a Floating Strategy When Slotted Inside `mds-button`

When `<mds-notification>` sits inside the `notification` slot of [`mds-button`](../mds-button/AGENTS.md), the button's own layout handles placement. Without a `target` the component switches itself to `strategy="disabled"`; giving it a `target` turns floating positioning back on, so the badge escapes the slot and positions itself relative to the viewport instead.

```html
<!-- INCORRECT -->
<mds-button id="btn-messaggi" label="Messaggi" icon="mdi/email" variant="primary">
  <mds-notification slot="notification" target="#btn-messaggi" value="5"></mds-notification>
</mds-button>

<!-- CORRECT -->
<mds-button id="btn-messaggi" label="Messaggi" icon="mdi/email" variant="primary">
  <mds-notification slot="notification" value="5" strategy="disabled"></mds-notification>
</mds-button>
```

#### Do Not Omit `target` When Using a Floating Strategy

Without `target`, the component cannot locate its anchor, automatically falls back to `strategy="disabled"`, and renders in document flow wherever the tag appears - usually in the wrong place.

```html
<!-- INCORRECT -->
<mds-notification value="3"></mds-notification>
<mds-icon id="icona-posta" name="mi/baseline/mail"></mds-icon>

<!-- CORRECT -->
<mds-notification target="#icona-posta" value="3"></mds-notification>
<mds-icon id="icona-posta" name="mi/baseline/mail"></mds-icon>
```

#### Do Not Use `<mds-notification>` as a Status Dot Without a Count

`<mds-notification>` is a numeric counter badge. For a purely visual status indicator with no count, use [`mds-badge`](../mds-badge/AGENTS.md) instead, which is designed for short status labels.

```html
<!-- INCORRECT - abusing notification as a plain dot indicator -->
<mds-notification target="#utente-online" value="0"></mds-notification>

<!-- CORRECT - use mds-badge for status dots -->
<mds-badge variant="success" label="Online"></mds-badge>
```

#### Do Not Animate the Dot Yourself

A pulse written by the page, with a keyframe, a scale and an opacity of its own, ignores the animation preference and never stops. `pulse` plays three beats when the count grows, and none with a reduced animation.

```html
<!-- INCORRECT -->
<mds-notification class="animate-ping" variant="info" value="3"></mds-notification>

<!-- CORRECT -->
<mds-notification variant="info" value="3" pulse></mds-notification>
```

#### Do Not Wrap the Target in a Relative Container and Use `strategy="fixed"`

`strategy="fixed"` anchors the badge to the viewport coordinate system. If the target sits inside a CSS-transformed or `position: relative` parent, `fixed` positioning will not track it correctly. Switch to `strategy="absolute"` and ensure the containing block has a non-static position.

```html
<!-- INCORRECT - fixed badge inside transformed container -->
<div style="transform: translateX(0);">
  <mds-notification target="#btn-azioni" value="2" strategy="fixed"></mds-notification>
  <mds-button id="btn-azioni" label="Azioni"></mds-button>
</div>

<!-- CORRECT - absolute strategy with positioned containing block -->
<div style="position: relative;">
  <mds-notification target="#btn-azioni" value="2" strategy="absolute"></mds-notification>
  <mds-button id="btn-azioni" label="Azioni"></mds-button>
</div>
```

#### Do Not Pierce Shadow DOM to Style the Inner Dot

The internal `.dot` element is not a documented `::part()`. Targeting it with `::part(dot)` or deep-selector hacks breaks on any internal refactor. The dot keeps the fill the component gives it, from its `variant`: adjust only what the public `--mds-notification-color` and `--mds-notification-size` CSS custom properties expose.

```css
/* INCORRECT */
mds-notification::part(dot) {
  background-color: purple;
}

/* CORRECT */
mds-notification {
  --mds-notification-size: calc(var(--spacing) * 600);
}
```
