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

# mds-table-cell

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

The `<mds-table-cell>` web component is the data-cell building block of the Magma table, designed to be slotted inside [`<mds-table-row>`](../mds-table-row/AGENTS.md). It plays the role of a single table cell (the equivalent of an HTML `<td>`) and wraps arbitrary content with the correct table semantics and styling.

#### Semantic Behavior

- **Compound child only**: Must be placed as a direct slot child of `<mds-table-row>` (or of `<mds-table-footer>`, which is itself a row). It is not used standalone, and a row should not mix cells with unrelated child types. The parent also injects its own `mds-table-cell` instances for the selection checkbox and row actions.
- **Sorting contribution**: The cell does not sort anything itself, but its `value` is read by `mds-table-header-cell` when sorting a column. If `value` is unset, the header cell falls back to the cell's trimmed text content.
- **Default slot passthrough**: Any text, HTML or component placed inside is projected as-is; there is no internal layout beyond styling.

#### Properties & Visual Configurations

This component is essentially a layout/semantic child and exposes a single non-obvious prop:

- **`value`**: Provide this when the cell's visible content is not directly comparable for sorting, when the displayed text differs from the value you want to sort by (e.g. a formatted date or currency string), or to get a numeric sort (two values that both read as numbers, such as `value="1250.50"`, are compared numerically). When omitted, the column sort uses the rendered text content instead.

There are no `variant` or `tone` props; visual presentation is controlled through the public CSS custom properties listed in [`AGENTS.md`](AGENTS.md): the background and text colors. The cells of the sorted column (the column whose `mds-table-header-cell` has a `direction`) take an alternate tone of their own.

## 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-table-cell--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 |
| --- | --- | --- | --- | --- |
| `value` | `value` | `number \| string \| undefined` | - | Sets a value to help the sorting function from `mds-table-header-cell`, if not set it will be used the content of the cell. |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `text string`, `HTML elements` or `components` to this slot. |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-table-cell-background` | Default background color of table cells. |
| `--mds-table-cell-color` | Default text color of table cells. |

Only these are public. Its other 2 are internal: they may change in any release, do not set them.

## Dependencies

Used by: `mds-table-footer`, `mds-table-header`, `mds-table-row`.
