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

# mds-entity

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

The `<mds-entity>` web component represents a person, organization, or resource as a compact identity block in the Magma Design System, pairing an avatar with a name, optional secondary details, and contextual actions. It has no native HTML equivalent; it standardises how entities are surfaced in lists, headers, and cards.

#### Semantic Behavior

- **Avatar resolution**: The leading avatar renders only when one of `src`, `icon`, or `initials` is provided. The inner `mds-avatar` resolves a combination pairwise: `icon` hides the `src` image, `initials` hide the `icon`, `src` hides the `initials`, and with all three set it shows none of them.
- **Await state**: While `await` is set the avatar is suppressed and a spinner is shown in its place, signalling that the entity is still loading.
- **Conditional regions**: The `detail` and `action` regions are shown only while content is projected into those slots, also when it is added after the first render.
- **Default slot is the name**: The default slot carries the entity's primary label (text, HTML, or components) and is always rendered inside the info column (the `infos` part), above the `detail` row.

#### Properties & Visual Configurations

- **`src`** is the path to an entity image; **`icon`** is a Magma icon library slug; **`initials`** is the text shown when no image or icon fits. Provide only the one that best identifies the entity - they are not combined.
- **`await`** marks the entity as loading and takes visual precedence over any avatar source.

The shared `tone` / `variant` ladders are defined in [`agents/variants.md`](../../../../agents/variants.md) and color the inner avatar. `tone` is limited to the minimal `'strong'` / `'weak'` pair, and `variant` accepts the avatar colour set; pick them to colour the avatar chip in line with the entity's category. With `initials` the avatar derives its colour from the letters and ignores `variant`.

#### Slots

- **`detail`** holds secondary information (role, email, status) rendered beneath the name.
- **`action`** holds trailing controls; `mds-button` is the recommended element here.

## 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-entity--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 |
| --- | --- | --- | --- | --- |
| `await` | `await` | `boolean \| undefined` | - | Specifies if the component is awaiting a response from an external resource |
| `icon` | `icon` | `string \| undefined` | - | Specifies the icon to be displayed if src propery is not used |
| `initials` | `initials` | `string \| undefined` | - | The user's inizials displayed if there's no image available and icon is not set |
| `src` | `src` | `string \| undefined` | - | Specifies the path to the image |
| `tone` | `tone` | `"strong" \| "weak" \| undefined` | - | Specifies the color tone of the component |
| `variant` | `variant` | `"amaranth" \| "aqua" \| "blue" \| "error" \| "green" \| "info" \| "lime" \| "orange" \| "orchid" \| "primary" \| "purple" \| "red" \| "sky" \| "success" \| "violet" \| "warning" \| "yellow" \| undefined` | - | Specifies the color variant of the component |

## Slots

| Slot | Description |
| --- | --- |
| (default) | Add `text string`, `HTML elements` or `components` to this slot. |
| `action` | Add `HTML elements` or `components`, it is **recommended** to use `mds-button` element. |
| `detail` | Add `HTML elements` or `components` to this slot. |

## Parts

| Part | Description |
| --- | --- |
| `avatar` | The avatar element |
| `infos` | The column that stacks the name (default slot) and the `detail` row |
| `spinner` | The spinner element |

## CSS custom properties

| Property | Description |
| --- | --- |
| `--mds-entity-background` | The background-color of the entity |
| `--mds-entity-color` | The color of the entity name |

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

## Dependencies

Uses: `mds-spinner`, `mds-avatar`.
