<!--
  GENERATED FILE - do not edit by hand.
  Source of truth: src/components/mds-card/ in the magma monorepo (usage/*.md and the
  component's JSDoc). Regenerated on every stencil build (scripts/component-docs.ts).
-->

# mds-card

> `@maggioli-design-system/magma` 2.15.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.

The `<mds-card>` web component is the surface container of the Magma Design System: a styled, self-contained panel that groups related media, heading, body and action content into a single bounded region. It is a pure layout shell built on named slots and compound children rather than a replacement for any single HTML primitive.

#### Semantic Behavior

- **Layout is inferred, not declared**: The card detects which of the `media` / `header` / `content` / `footer` regions are present, again whenever its content changes, and reshapes itself to whatever content you provide.
- **Compound parent/child relationship**: `<mds-card-media>`, `<mds-card-header>`, `<mds-card-content>` and `<mds-card-footer>` are recognized by tag name and mapped onto the corresponding region, so they slot in without an explicit `slot` attribute. Plain elements given the matching `slot` value land in that region and take part in the managed grid the same way.
- **Responsive by width**: The card's internal layout switches between stacked and media-beside-content arrangements based on the card's own width, independent of viewport or theme.
- **One inset, shared by the regions**: The card pads its regions once, with `--magma-rhythm-inset` (600), and sets them `--magma-rhythm-title-content` (300) apart, so the title of a card stands nearer to its content than to the edge. The regions pad nothing of their own (`rhythm/inset`, `rhythm/shared-inset` in the design language).
- **The media reaches the edges it touches**: `<mds-card-media>` leaves the inset on the sides where it meets the edge of the card: both sides when the regions are stacked, the top too when no header stands above it, the top, the bottom and the start when it stands beside the content. From the other regions it stands 300, as they do from each other (`rhythm/media-bleed`).
- **The actions stand apart**: The footer stands `--magma-rhythm-content-actions` (600) from the region before it, as the row of actions of a form or of a dialog: the actions act on the whole card, not on its last line (`rhythm/content-actions`).
- **The footer closes the card**: The footer region sits at the bottom of the card whatever the other regions are. When the card is taller than its parts (a media taller than header and footer together, or a grid row that stretches a set of cards to one height) and there is no content to take the free space, that space stays above the footer, in the card's background.
- **The card sets the text of its own surface**: It paints `surface-raised` and sets its `color` to `text-default`, the pair the contrast gate measures, so its regions inherit the text of the card, not the colour of what the card stands on: on a band of colour (`surfaces/intro-band`) its text keeps reading without a reset. A `text-*` class or a `color` on the host still wins.
- **Slot regions are fixed**: Only the four named regions are rendered; there is no default (unnamed) slot, so loose text or elements without a recognized slot/tag are not laid out.

#### Properties & Visual Configurations

`<mds-card>` does not use the shared `variant` / `tone` ladders defined in [`agents/variants.md`](../../../../agents/variants.md); it exposes a single behavioral prop.

- **`disableAutoGrid`** (default `false`) toggles the intrinsic responsive grid. Leave it off to let the card own the placement and reflow of its regions; set it to opt out of the managed grid and lay the slotted content out yourself.

The inset and the gap follow the rhythm roles, so a density theme moves them with every other space. `--mds-card-padding` and `--mds-card-gap` override them for a set of cards, with another rhythm role, never a step; the background of the card and of its regions is `--mds-card-background`, its text `--mds-card-color`: set them together, so the text keeps reading on the surface.

## Read next

- [`examples.md`](examples.md) - correct usage, from the most common case
- [`mistakes.md`](mistakes.md) - the wrong forms, each with the right one
- [Storybook](https://magma-design-system.github.io/magma/storybook/?path=/docs/layout-card--docs) - the live examples, in the published Storybook of `main`
- [`conventions.md`](../../../../agents/conventions.md), [`variants.md`](../../../../agents/variants.md), [`mistakes.md`](../../../../agents/mistakes.md) - the rules shared by every component

## Props

| Prop | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `disableAutoGrid` | `disable-auto-grid` | `boolean` | `false` | Disables the automatic responsive behavior based on container queries |

## Slots

| Slot | Description |
| --- | --- |
| `content` | Add `HTML elements` or `components`, it's responsive behaviour based on container queries is handled with `auto-grid` enabled |
| `footer` | Add `HTML elements` or `components`, it's responsive behaviour based on container queries is handled with `auto-grid` enabled |
| `header` | Add `HTML elements` or `components`, it's responsive behaviour based on container queries is handled with `auto-grid` enabled |
| `media` | Add `HTML elements` or `components`Add `HTML elements` or `components`, it is **recommended** to use `mds-img` element or other component to represent media contents, used for images or videos, it's responsive behaviour based on container queries is handled with `auto-grid` enabled |

## Parts

| Part | Description |
| --- | --- |
| `layout` | The layout element that wraps the slotted content |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-card-background` | Sets the background color of the card and of its regions (`mds-card-header`, `mds-card-media`, `mds-card-content`, `mds-card-footer`) |
| `--mds-card-color` | Sets the text color of the card, inherited by its regions, `--magma-text-default` by default: set it together with `--mds-card-background`, so the text keeps reading on the surface |
| `--mds-card-gap` | Sets the space between the regions of the card, `--magma-rhythm-title-content` by default; the footer keeps at least `--magma-rhythm-content-actions` from the region before it |
| `--mds-card-padding` | Sets the inset of the card, shared by its regions, `--magma-rhythm-inset` by default; the media region reaches out of it to the edges it touches |
