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

# mds-table-header

> `@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-header>` web component is the header region of a Magma table, used exclusively as a direct slot child of its parent [`<mds-table>`](../mds-table/AGENTS.md). It plays the role of an HTML `<thead>`/header row, hosting the column-header cells and, when selection is enabled, the master "select all" control.

#### Semantic Behavior

- **Compound child only**: Must be slotted directly inside `<mds-table>` alongside `mds-table-body` (and optionally `mds-table-footer`); it is not used standalone. It is itself the header row: its own default slot accepts `mds-table-header-cell` element(s), one per column.
- **Parent-driven selection state**: When `selectable` is true the header renders a master checkbox that the parent keeps in sync - `indeterminate` for partial selection and `checked` when all rows are selected, rows selected in the markup on load included.
- **Selection reported upward**: Toggling the master checkbox selects or deselects every row, after which the table re-emits its own `mdsTableSelectionChange` event.
- **Automatic actions column**: When any row exposes a `[slot="action"]`, the header appends an extra header cell (exposed as the `actions` shadow part) labelled with the localized "actions" string.
- **Localized labels**: The select-all/select-none switch title and the actions label are localized (el/en/es/it). The title says what a click on the switch does: select every row, or deselect them once every row is selected, however they got selected.

#### Properties & Visual Configurations

This child is configured almost entirely by its parent rather than by author-set attributes.

- **`selectable`**: Toggles rendering of the leading master-checkbox column. It is not normally set by hand - `<mds-table>` propagates its own `selectable` prop down to the header, so enabling selection on the table is what surfaces this control here.

Beyond `selectable`, content is provided through the default slot (`mds-table-header-cell` elements); there are no shared `variant`/`tone` ladders on this component.

## 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-header--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 |
| --- | --- | --- | --- | --- |
| `selectable` | `selectable` | `boolean \| undefined` | - | Enables the select-all checkbox in the header. |

## Methods

| Method | Signature | Description |
| --- | --- | --- |
| `setActions` | `setActions(hasActions: boolean) => Promise<void>` | `internal` Shows or hides the Actions column: mds-table calls it whenever its rows gain or lose `slot="action"` content, the header itself reads them only on load |
| `setSelection` | `setSelection(selectedItems: number, totalItems: number) => Promise<void>` | Updates the header's select-all state from the number of selected rows. |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `mds-table-header-cell` element/s, one per column: the header is itself the row of the column headings. |

## Parts

| Part | Description |
| --- | --- |
| `actions` | The heading of the Actions column, shown while rows have `slot="action"` content |

## Dependencies

Uses: `mds-table-cell`, `mds-input-switch`, `mds-table-header-cell`.
