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

# mds-card - mistakes

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

Common incorrect uses of `<mds-card>`. 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 Put Content Outside the Four Named Slots

`<mds-card>` has no default (unnamed) slot. Loose text or elements placed without a recognized `slot` attribute - or without using an `mds-card-*` compound child - are silently ignored and never rendered.

```html
<!-- INCORRECT -->
<mds-card>
  <p>Questo testo non verra' mai visualizzato.</p>
  <mds-button label="Azione"></mds-button>
</mds-card>

<!-- CORRECT -->
<mds-card>
  <mds-card-content>
    <mds-text>Questo testo e' correttamente posizionato nel content slot.</mds-text>
  </mds-card-content>
  <mds-card-footer>
    <mds-button label="Azione" variant="primary"></mds-button>
  </mds-card-footer>
</mds-card>
```

#### Do Not Use `mds-card-*` Children Outside `<mds-card>`

Compound children (`mds-card-header`, `mds-card-media`, `mds-card-content`, `mds-card-footer`) rely on `<mds-card>` for layout context. Used standalone they render without the managed grid and without the card's visual chrome.

```html
<!-- INCORRECT -->
<div class="mia-sezione">
  <mds-card-header>
    <mds-text typography="h6">Titolo standalone</mds-text>
  </mds-card-header>
</div>

<!-- CORRECT -->
<mds-card>
  <mds-card-header>
    <mds-text typography="h6">Titolo nella scheda</mds-text>
  </mds-card-header>
</mds-card>
```

#### Do Not Pierce the Shadow DOM with Undocumented Selectors

The only supported customization surface is `--mds-card-background`, `--mds-card-color`, `--mds-card-gap`, `--mds-card-padding`, and `::part(layout)`. Targeting internal class names with `>>>`, `/deep/`, or any selector that reaches inside the shadow root couples your code to implementation details and will break on minor releases.

```css
/* INCORRECT */
mds-card >>> .layout {
  padding: 16px;
}
mds-card .layout--cfhm {
  grid-template-columns: 1fr 1fr;
}

/* CORRECT */
mds-card {
  --mds-card-padding: calc(var(--spacing) * 400);
}
mds-card::part(layout) {
  border-radius: var(--magma-radius-xl);
}
```

#### Do Not Assign an Explicit `slot` Attribute to `mds-card-*` Children

`mds-card-header`, `mds-card-media`, `mds-card-content`, and `mds-card-footer` already set their own `slot` attribute on the host element from inside the component. Adding it again from the outside is redundant and may conflict with internal wiring.

```html
<!-- INCORRECT -->
<mds-card>
  <mds-card-header slot="header">...</mds-card-header>
  <mds-card-content slot="content">...</mds-card-content>
</mds-card>

<!-- CORRECT -->
<mds-card>
  <mds-card-header>...</mds-card-header>
  <mds-card-content>...</mds-card-content>
</mds-card>
```

#### Do Not Put Media Elements Directly in the `header` Slot

The `header` slot is intended for title and action controls. Placing an `<mds-img>` or `<img>` directly there bypasses the media region's responsive two-column behavior. Use the `media` slot (or `<mds-card-media>`) for images and videos.

```html
<!-- INCORRECT -->
<mds-card>
  <mds-card-header>
    <mds-img src="/immagini/banner.jpg" alt="Banner della campagna"></mds-img>
  </mds-card-header>
</mds-card>

<!-- CORRECT -->
<mds-card>
  <mds-card-media>
    <mds-img src="/immagini/banner.jpg" alt="Banner della campagna" class="object-cover"></mds-img>
  </mds-card-media>
  <mds-card-header>
    <mds-text typography="h6">Titolo della scheda</mds-text>
  </mds-card-header>
</mds-card>
```

#### Do Not Pad the Regions of a Card

The card pads its regions once, with its inset. A padding on a region, or on a plain element in a slot, adds to the inset: the title moves away from the edge and from its content, as when every region padded `p-400` of its own and the title stood 800 from its text. A padding on the media also takes it away from the edges it should reach.

```html
<!-- INCORRECT -->
<mds-card>
  <mds-card-header class="p-400">
    <mds-text typography="h6">Riepilogo ordine</mds-text>
  </mds-card-header>
  <mds-text slot="content" class="px-400">Il tuo ordine e' stato elaborato correttamente.</mds-text>
</mds-card>

<!-- CORRECT -->
<mds-card>
  <mds-card-header>
    <mds-text typography="h6">Riepilogo ordine</mds-text>
  </mds-card-header>
  <mds-card-content>
    <mds-text>Il tuo ordine e' stato elaborato correttamente.</mds-text>
  </mds-card-content>
</mds-card>
```

#### Do Not Override Card Dimensions with Inline Styles

`<mds-card>` manages its own min-height and responsive grid. A fixed `height` clips the regions (the card hides its overflow), and a fixed `width` pins the container-query layout instead of letting it follow the space its container gives.

```html
<!-- INCORRECT -->
<mds-card style="width: 300px; height: 200px;">
  ...
</mds-card>

<!-- CORRECT: size the card from a parent container or CSS custom properties -->
<div class="w-[300px]">
  <mds-card>
    ...
  </mds-card>
</div>
```
