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

# mds-tab-bar-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-bar-item>` web component is a single selectable tab within the [`<mds-tab-bar>`](../mds-tab-bar/AGENTS.md) container. It renders an icon stacked over a text label and acts as one option in the bar's mutually-exclusive selection group.

#### Semantic Behavior

- **Compound child only**: Must be placed as a direct default-slot child of `<mds-tab-bar>`; it is not used standalone or mixed with other child types.
- **Parent-coordinated selection**: Clicking an item that is not selected selects it and emits `mdsTabBarItemSelect` carrying its own `id`; a click on the selected item changes nothing and emits nothing. The parent re-drives every sibling's `selected` so exactly one item is active at a time - items do not deselect each other on their own.
- **Whole-host click target**: The entire item (icon + label) is the click surface, not just the text. It is a button (`role="button"`, unless you set another role) in the tab order, activated by Enter and Space as by a click; the selected item carries `aria-current="true"`.
- **Label is text**: Set the visible text with the `label` prop. The default slot is a **deprecated** fallback kept for backward compatibility - slotted text is read into `label`, while nested HTML is stripped with a console warning; avoid placing HTML elements or other components there.

#### Properties & Visual Configurations

- **`icon`**: Icon name shown above the label; use it to give the tab a recognizable glyph. Optional - defaults to empty.
- **`label`**: The tab's visible text. This is the preferred and idiomatic way to set the text, matching the `label` prop on [`mds-button`](../mds-button/AGENTS.md) and other Magma components.
- **`selected`**: Marks this item as the active tab. You typically do not toggle it manually at runtime - the parent manages it - but you can set it on one item as the initial active tab.
- **`typography`**: Controls the label's text style, constrained to the smaller typography set (`tip` by default, or `option`). Pick `option` for a slightly more prominent label.

The resting appearance is configured through the public `--mds-tab-bar-item-background` and `--mds-tab-bar-item-color` CSS custom properties listed in [`AGENTS.md`](AGENTS.md); the selected item keeps its own accent colouring.

## 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-bar-tab-bar-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 |
| --- | --- | --- | --- | --- |
| `icon` | `icon` | `string` | `''` | The icon displayed in the tab bar item. |
| `label` | `label` | `string \| undefined` | - | Sets the label of the tab bar item |
| `selected` | `selected` | `boolean` | - | Specifies if the component is selected or not |
| `typography` | `typography` | `"option" \| "tip" \| undefined` | `'tip'` | Specifies the typography of the element |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsTabBarItemSelect` | `string` | Emits when the component is selected |

## Slots

| Slot | Description |
| --- | --- |
| (default) | **Deprecated**, use the `label` property instead. Add `text string` to this slot, **avoid** to add `HTML elements` or `components` here. |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-tab-bar-item-background` | Sets the background-color of the component |
| `--mds-tab-bar-item-color` | Sets the text color of the component |

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

## Dependencies

Uses: `mds-icon`, `mds-text`.
