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

# mds-tab-item

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

The `<mds-tab-item>` web component is the individual, clickable tab control of the Magma Design System, designed to be slotted into the default slot of its parent [`<mds-tab>`](../mds-tab/AGENTS.md). It acts as the trigger that switches the matching `content`-slotted panel inside the tab group.

#### Semantic Behavior

- **Compound child only**: Must be a direct child of `<mds-tab>` placed in its default slot; it is not used standalone, and the matching panel content is added separately into the parent's `content` slot (one per `<mds-tab-item>`, or none when the page shows the content itself). Mixing it with other child types breaks the parent's pairing.
- **Link item**: With `href` the item renders a real link instead of a tab: it is announced as a link, with `aria-current` when selected, and the browser follows it, in a new tab on a modifier or middle click. A `click` listener on the item cancels the navigation with `preventDefault()` to route on the client; the selection still moves, except on a modifier click, which the browser opens elsewhere.
- **Selection driven by the parent**: Clicking the item emits `mdsTabItemSelect`; `<mds-tab>` sets `selected` on the chosen item, clears it on the others, and reveals the corresponding panel.
- **Initial selection**: Marking one item `selected` in markup tells the parent which tab is active on load.
- **Focus reporting**: A key press emits `mdsTabItemFocus`, which the parent uses to scroll the focused tab into view; both events carry `{ target, value }` so the parent can resolve the item even with a custom `id`.
- **Disabled guard**: When `disabled`, the item cannot be selected via pointer or keyboard.
- **Sizing managed upstream**: `size` is pushed down from `<mds-tab>`, overriding the item's own `size` prop.

#### Properties & Visual Configurations

This child does not use the shared `variant`/`tone` ladders; its props mirror the underlying `<mds-button>`.

- **`value`**: Set this to identify the tab in the `mdsTabItemSelect` payload (and the parent's `mdsTabChange`) when you need to react to selection without relying on DOM index or `id`.
- **`type`**: Defaults to `submit`; pick `button` for a plain tab that does not interact with a surrounding form. With `href` the item is a link and `type` has no effect.
- **`icon`** / **`iconPosition`**: Add a leading (`left`, default) or trailing (`right`) glyph; use the trailing position for affordances like an external-link or dismiss hint.
- **`await`**: Reflects the button's awaiting/loading state for tabs whose activation triggers an async operation.
- **`size`**: Defaults to `md`, but is normally controlled by the parent's `size` prop, so set it on `<mds-tab>` for consistent sizing across all items.

## 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/ui-tab-tab-item--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 |
| --- | --- | --- | --- | --- |
| `animation` | `animation` | `"fade" \| "slide" \| undefined` | - | Reflects the parent tab selection animation (set by mds-tab); drives the slide-variant styling without :host-context |
| `await` | `await` | `boolean` | - | Specifies if the button is awaiting for a response |
| `direction` | `direction` | `"horizontal" \| "vertical" \| undefined` | - | Reflects the parent tab layout direction (set by mds-tab); drives the vertical layout without :host-context |
| `disabled` | `disabled` | `boolean \| undefined` | - | Specifies if the tab item is disabled or not |
| `expanded` | `expanded` | `boolean \| undefined` | - | Specifies whether the popup the tab item opens is showing. Left unset the tab says nothing about a popup, which is what a tab that opens none has to say. |
| `href` | `href` | `string \| undefined` | - | Turns the tab into a link to this URL: the item renders a real anchor and is announced as a link, not as a tab, with `aria-current` when selected. A client-side router registered with `NavigationService.setHandler()` (from `@maggioli-design-system/magma/services`) takes the plain clicks over; without one, a click listener on the host can still cancel the navigation with `preventDefault()`. |
| `icon` | `icon` | `string \| undefined` | - | The icon displayed in the tab item |
| `iconPosition` | `icon-position` | `"left" \| "right" \| undefined` | `'left'` | Specifies the horizontal position of the icon displayed in the tab item |
| `label` | `label` | `string \| undefined` | - | The label of the tab item |
| `selected` | `selected` | `boolean \| undefined` | - | Specifies if the tab item is selected or not |
| `size` | `size` | `"lg" \| "md" \| "sm" \| "xl" \| undefined` | `'md'` | Specifies the size for the tab item |
| `type` | `type` | `"a" \| "button" \| "reset" \| "submit" \| undefined` | `'submit'` | The type of the tab item element |
| `value` | `value` | `string \| undefined` | - | Specifies an optional value to get from mdsTabItemSelect event |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsTabItemFocus` | `MdsTabItemEventDetail` | Emits when the tab item is selected |
| `mdsTabItemSelect` | `MdsTabItemEventDetail` | Emits when the tab item is selected |

## Parts

| Part | Description |
| --- | --- |
| `button` | The `mds-button` of the tab |

## CSS custom properties

None is public: its 5 custom properties are internal and may change in any release. Style it with its props, its parts and the semantic roles.

## Dependencies

Uses: `mds-button`.
Used by: `mds-input-date-range`, `mds-input-upload`, `mds-pref-animation`, `mds-pref-consumption`, `mds-pref-contrast`, `mds-pref-language`, `mds-pref-mode`, `mds-pref-theme`.
