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

# mds-chip

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

The `<mds-chip>` web component is the Magma Design System's compact element for representing a discrete piece of information, a filter, a selection, or a removable token. It renders a label with an optional leading icon or colour swatch and an optional delete affordance, and can be made interactive (clickable or selectable) to act as a lightweight button-like control rather than a static tag.

#### Semantic Behavior

- **Static by default**: With no interaction props the chip is a passive, non-focusable label; it becomes a focusable, button-like control only when `clickable` is set.
- **Selectable implies clickable**: Setting `selectable` automatically turns on `clickable`, so a selectable chip is always keyboard- and pointer-interactive.
- **Selection toggle**: When `selectable`, activating the chip flips `selected`; an unselected chip carries no `selected` attribute (rather than `selected="false"`).
- **Keyboard activation**: When interactive, Enter and Space activate the chip just like a pointer click.
- **Delete affordance**: When `deletable`, a trailing delete button is rendered with a localized title (el/en/es/it) and emits the delete event on activation.
- **Emitted events**: `mdsChipClickLabel` fires on activation for non-selectable chips, `mdsChipSelect` fires (carrying the new `selected` value) for selectable chips, and `mdsChipDelete` fires from the delete button - all carrying the originating event and host element.
- **Label is text, on one line**: Long labels do not wrap (`truncate="word"` on the inner text).
- **One leading mark**: `swatch` takes the place of `icon`; when both are set the chip draws the swatch. The swatch is decorative and hidden from assistive technologies, so the label has to name the colour.

#### Properties & Visual Configurations

The shared `variant` / `tone` ladders are defined in [`agents/variants.md`](../../../../agents/variants.md); the chip defaults to `variant="primary"` and `tone="strong"`, and accepts only the minimal `'strong'` / `'weak'` tone set. `variant` and `tone` paint the leading icon badge and the border of a selected chip; the body of the chip stays neutral for every variant.

#### Other behavioral props

- **`clickable`** opts the chip into interactivity (focus, keyboard and click handling) without changing its state on activation - use it for chips that act as actions rather than toggles.
- **`selectable`** makes the chip a toggle whose `selected` state flips on each activation; pick it for filter/choice chips where the visual selected state matters.
- **`selected`** drives the selected visual treatment and can be set externally to pre-select a chip; an unselected chip carries no attribute.
- **`deletable`** adds the trailing cancel button for removable tokens; reserve it for chips the user is meant to dismiss.
- **`icon`** is an SVG filename slug from the Magma icon library, shown decoratively to the left of the label.
- **`swatch`** is a colour of the product, any CSS colour, drawn as a round swatch where the icon goes: for chips whose label names a colour (a family of colours, a category, a calendar). It is not a role and does not follow `variant` or the mode: the chip draws it as given, inside a ring that keeps it visible on the chip at rest and selected, in light and dark. A value that is not a colour draws the empty ring.

## 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-chip--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 |
| --- | --- | --- | --- | --- |
| `clickable` | `clickable` | `boolean \| undefined` | - | Adds ARIA support to the element if has interaction |
| `deletable` | `deletable` | `boolean \| undefined` | - | Shows the cross icon to perform cancel/delete action on element |
| `disabled` | `disabled` | `boolean \| undefined` | `false` | Sets the component disabled status: neither the label nor the delete button can be focused or activated |
| `icon` | `icon` | `string \| undefined` | - | The icon displayed to the left of the component's label |
| `label` | `label` | `string` | - | **Required**. The label displayed to the right of the component's icon |
| `selectable` | `selectable` | `boolean \| undefined` | `false` | Sets if the component change is status to selected when is clicked |
| `selected` | `selected` | `boolean \| undefined` | - | Sets the component selected |
| `swatch` | `swatch` | `string \| undefined` | - | A colour drawn as a round swatch where the icon goes, in place of `icon`: any CSS colour (`#2f6fd0`, `rgb(47 111 208)`, `oklch(55% 0.2 260)`). It is a value of the product, the colour the label names (a family of colours, a category, a calendar), not a role of Magma: the chip draws it as it is given in every mode and theme, inside a ring that keeps it visible on the chip, at rest and selected. Decorative: hidden from assistive technologies, since the label names it. A value that is not a colour draws the empty ring. |
| `tone` | `tone` | `"strong" \| "weak" \| undefined` | `'strong'` | Sets the color variant tone of the component |
| `variant` | `variant` | `"ai" \| "amaranth" \| "aqua" \| "blue" \| "dark" \| "error" \| "green" \| "info" \| "lime" \| "orange" \| "orchid" \| "primary" \| "purple" \| "red" \| "secondary" \| "sky" \| "success" \| "violet" \| "warning" \| "yellow" \| undefined` | `'primary'` | Sets the color variant of the component |

## Events

| Event | Detail | Description |
| --- | --- | --- |
| `mdsChipClickLabel` | `MdsChipEvent` | Emits when the component's label is clicked |
| `mdsChipDelete` | `MdsChipEvent` | Emits when the component's delete button is clicked |
| `mdsChipSelect` | `MdsChipEvent` | Emits when the component's label is clicked and when `selectable` attribute is set to `true` |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-chip-background` | Sets the `background-color` of the component |
| `--mds-chip-color` | Sets the `color` of the component |
| `--mds-chip-icon-background` | Sets the `background-color` of the icon |
| `--mds-chip-shadow` | Sets the `box-shadow` of the component |

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

## Dependencies

Uses: `mds-icon`, `mds-text`, `mds-button`.
Used by: `mds-policy-ai`.
