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

# mds-text - mistakes

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

Common incorrect uses of `<mds-text>`. 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 Slot HTML Elements in the Default Slot

The default slot accepts plain text strings only. HTML elements or components slotted inside are outside the supported API: they keep their own browser and page styles instead of following the typography role. The one exception is `<mds-link>`, a word of the sentence that takes the font of the role.

```html
<!-- INCORRECT -->
<mds-text typography="paragraph">
  <strong>Attenzione:</strong> questa operazione e' <em>irreversibile</em>.
</mds-text>

<!-- CORRECT -->
<mds-text typography="paragraph">Attenzione: questa operazione e' irreversibile.</mds-text>
<mds-text typography="paragraph" tag="strong">Attenzione:</mds-text>
```

#### Do Not Mix `text` Prop and Slotted Content

When `text` is set, the component renders that string and ignores the slot entirely. Do not provide both - the slotted content is silently discarded.

```html
<!-- INCORRECT -->
<mds-text text="Titolo dal prop">Titolo dallo slot</mds-text>

<!-- CORRECT -->
<!-- Use either the prop (preferred for dynamic / animated content) -->
<mds-text text="Titolo dal prop"></mds-text>
<!-- or the slot (convenient for static markup) -->
<mds-text>Titolo dallo slot</mds-text>
```

#### Do Not Use `animation="yugop"` Without the `text` Prop

The yugop animation requires the `text` prop because it watches prop changes to retrigger. Slotted content is not observed; changing it will not re-run the animation.

```html
<!-- INCORRECT -->
<mds-text animation="yugop">Testo animato dallo slot</mds-text>

<!-- CORRECT -->
<mds-text animation="yugop" text="Testo animato dal prop"></mds-text>
```

#### Do Not Apply an Invalid `variant` for the Chosen `typography`

`variant` is specific to the typography role: only `paragraph`, `detail`, and `caption` accept `variant="read"`. Applying `variant="read"` to heading or label roles silently has no visual effect and adds misleading markup.

```html
<!-- INCORRECT -->
<mds-text typography="h2" variant="read">Impostazioni</mds-text>
<mds-text typography="label" variant="read">Nome</mds-text>

<!-- CORRECT -->
<mds-text typography="h2">Impostazioni</mds-text>
<mds-text typography="paragraph" variant="read">Testo editoriale lungo.</mds-text>
```

#### Do Not Style a Title by Its Level

A title is written by its role, not by the level it happens to look like: a level ties the title to one style, and a theme that moves the title of a page would have to move every `h3`. Nor does the tag choose the style: the title of a page is the one `h1` of the page and keeps the style of its role.

```html
<!-- INCORRECT -->
<mds-text typography="h1">Pratiche di residenza</mds-text>
<mds-text typography="h3" tag="h1">Pratiche di residenza</mds-text>

<!-- CORRECT -->
<mds-text typography="page" tag="h1">Pratiche di residenza</mds-text>
```

#### Do Not Use Raw HTML Headings Instead of `<mds-text>`

Replace raw `<h1>`-`<h6>`, `<p>`, `<span>`, `<label>`, and `<code>` styled with generic utilities with `<mds-text>` in Magma-managed views (or apply the typography utilities of [`agents/typography.md`](../../../../agents/typography.md)). Generic sizes and weights bypass the design-token typography ramp, causing visual inconsistency across themes and sizes.

```html
<!-- INCORRECT -->
<h2 class="text-2xl font-bold">Riepilogo ordine</h2>
<p class="text-sm text-fg-muted">Totale: 128,00 EUR</p>

<!-- CORRECT -->
<mds-text typography="section" tag="h2">Riepilogo ordine</mds-text>
<mds-text typography="caption">Totale: 128,00 EUR</mds-text>
```

#### Do Not Reach Into Shadow DOM to Style Internal Elements

The component exposes three public `--mds-text-*` CSS custom properties for customization (the animation speed, the animation placeholder character and the line clamp); the other text styles are set on the host. Do not pierce the shadow DOM via `::part()` or `>>>` selectors targeting the internal `.text` element - that implementation detail is not a documented part and may change.

```css
/* INCORRECT */
mds-text >>> .text {
  letter-spacing: 0.1em;
}

/* CORRECT - set via host; the host styles cascade into the shadow text node */
mds-text {
  letter-spacing: 0.1em;
}
```

#### Do Not Confuse `truncate="word"` and `truncate="all"`

`truncate="word"` forces **single-line** truncation. `truncate="all"` enables **multi-line** clamping controlled by `--mds-text-line-clamp`. Using `"word"` when you want multi-line clamp will collapse the text to one line unexpectedly.

```html
<!-- INCORRECT - collapses to one line when two lines were intended -->
<mds-text typography="paragraph" truncate="word" style="--mds-text-line-clamp: 2;">
  Testo lungo che dovrebbe mostrare due righe prima del troncamento.
</mds-text>

<!-- CORRECT -->
<mds-text typography="paragraph" truncate="all" style="--mds-text-line-clamp: 2;">
  Testo lungo che dovrebbe mostrare due righe prima del troncamento.
</mds-text>
```

#### Do Not Center Only the Lines of a Paragraph

A paragraph (the tag `p`, the default of `detail` and `paragraph`) stops at the reading measure. In a wider column, `text-center` centers its lines inside a box that still starts at the left edge, so the text looks pushed to one side: center the box as well.

```html
<!-- INCORRECT - the lines are centered in a 56ch box at the start of the column -->
<mds-text typography="paragraph" class="text-center">
  Nessun risultato corrisponde ai filtri scelti.
</mds-text>

<!-- CORRECT -->
<mds-text typography="paragraph" class="mx-auto text-center">
  Nessun risultato corrisponde ai filtri scelti.
</mds-text>
```
