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

# mds-pref-language-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-pref-language-item>` web component represents a single selectable language option inside the language-preference picker [`<mds-pref-language>`](../mds-pref-language/AGENTS.md). It renders one row of the parent's dropdown and reports the user's choice up to the parent rather than changing the page language itself.

#### Semantic Behavior

- **Compound child only**: Must be placed as a direct default-slot child of `<mds-pref-language>`; it is not used standalone or mixed with other child types.
- **Code validation**: `code` must match an entry in the bundled language dictionary; an unknown `code` logs a console warning and the item shows the code itself in place of a language name. When `code` is empty the item renders an error-toned fallback button instead of a language label.
- **Label is derived, not authored**: The visible language name is looked up from `code` (e.g. `it` to `Italiano`), so consumers supply only the code, not the display text.
- **Selection is parent-driven**: The `selected` prop is owned and toggled by `<mds-pref-language>`, which clears every sibling and sets only the active item.
- **Click emits, does not commit**: Clicking the item emits the bubbling `mdsPrefLanguageItemSelect` event carrying `{ language: code }`. The parent updates selection state, persists the preference, applies the document language, and emits its own `mdsPrefLanguageChange` - this child performs none of that.

#### Properties & Visual Configurations

The only meaningful prop is `code`: the BCP 47 / RFC 5646 language tag (such as `it`, `en`, `es`) that both keys the label lookup and is the payload emitted on selection. The accepted codes are the keys of the bundled language dictionary: the two-letter ISO 639-1 codes (`it`, `en`, `fr`, `de`, `zh`, ...) plus `ceb`, `haw` and `hmn`, which the parent cannot apply (its `set` accepts only `xx` / `xx-XX` codes).

`selected` is a state flag managed by the parent rather than a configuration choice. Sizing and styling are fixed by the parent's layout, so this item exposes no `variant` / `tone` of its own; the shared ladders in [`agents/variants.md`](../../../../agents/variants.md) are applied internally and are not configurable from the host.

## 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-preferences-language-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 |
| --- | --- | --- | --- | --- |
| `code` | `code` | `string` | - | Specifies the language code based on HTML `lang` attribute |
| `selected` | `selected` | `boolean \| undefined` | `false` | Specifies if the element is selected |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsPrefLanguageItemSelect` | `MdsPrefLanguageEventDetail` | Emits when the component trigger the language |

## Dependencies

Uses: `mds-button`.
