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

# mds-table-cell - mistakes

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

Common incorrect uses of `<mds-table-cell>`. 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-table-cell>` Outside Its Parent Hierarchy

`<mds-table-cell>` is a compound child; it must be placed inside `<mds-table-row>` or `<mds-table-footer>` (themselves inside `<mds-table>`). Rendering it standalone breaks the table layout and ARIA semantics entirely.

```html
<!-- INCORRECT -->
<div class="my-grid">
  <mds-table-cell>Nome</mds-table-cell>
  <mds-table-cell>Email</mds-table-cell>
</div>

<!-- CORRECT -->
<mds-table>
  <mds-table-body>
    <mds-table-row>
      <mds-table-cell><mds-text typography="detail">Nome</mds-text></mds-table-cell>
      <mds-table-cell><mds-text typography="detail">Email</mds-text></mds-table-cell>
    </mds-table-row>
  </mds-table-body>
</mds-table>
```

#### Do Not Use `<td>` in Place of `<mds-table-cell>`

Using raw `<td>` inside `<mds-table-row>` bypasses Magma theming, the `sorted` state styles, and the sort-value integration. Always use `<mds-table-cell>`.

```html
<!-- INCORRECT -->
<mds-table-row>
  <td>Mario Rossi</td>
  <td>mario.rossi@esempio.it</td>
</mds-table-row>

<!-- CORRECT -->
<mds-table-row>
  <mds-table-cell><mds-text typography="detail">Mario Rossi</mds-text></mds-table-cell>
  <mds-table-cell><mds-text typography="detail">mario.rossi@esempio.it</mds-text></mds-table-cell>
</mds-table-row>
```

#### Do Not Skip `value` When Displaying Formatted Data in a Sortable Column

If a cell shows a formatted value (localized date, currency, percentage) and the column is sortable, omitting `value` causes the sort to compare the human-readable strings lexicographically, producing wrong order.

```html
<!-- INCORRECT: "12 marzo 2024" sorts before "2 gennaio 2024" lexicographically -->
<mds-table-cell>
  <mds-text typography="detail">12 marzo 2024</mds-text>
</mds-table-cell>

<!-- CORRECT: ISO date in value drives sort; display string is for humans -->
<mds-table-cell value="2024-03-12">
  <mds-text typography="detail">12 marzo 2024</mds-text>
</mds-table-cell>
```

#### Do Not Style Cells by Piercing Shadow DOM

`<mds-table-cell>` does not expose named `::part()` targets; the supported customization surface is the public `--mds-table-cell-background` and `--mds-table-cell-color`. Targeting internals via `>>>` or undocumented selectors couples your code to implementation details that can change.

```css
/* INCORRECT */
mds-table-cell >>> span {
  color: red;
}

/* CORRECT */
mds-table-cell {
  --mds-table-cell-color: rgb(var(--magma-danger-fg));
}
```

#### Do Not Wrap `<mds-table-cell>` in Extra Structural Elements

Inserting a `<div>` or `<span>` wrapper around `<mds-table-cell>` inside `<mds-table-row>` breaks the `display: table-cell` layout model and disrupts the column alignment.

```html
<!-- INCORRECT -->
<mds-table-row>
  <div class="cell-wrapper">
    <mds-table-cell><mds-text typography="detail">Cognome</mds-text></mds-table-cell>
  </div>
</mds-table-row>

<!-- CORRECT -->
<mds-table-row>
  <mds-table-cell><mds-text typography="detail">Cognome</mds-text></mds-table-cell>
</mds-table-row>
```
