# Entity Chip

A person, team or company named inline, with its monogram.

A person, team or company named inline, with its monogram. Monogram (our avatar) + name in a soft field pill. Names a supplier, person or record inside running text. A name longer than the container truncates at the end; the root carries the full name as its title. The name reads in its own direction (unicode-bidi: plaintext), so a right-to-left name or a signed value stays intact on either page.

Kind: component · Category: Display · Status: stable · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add entity-chip
```

It writes the folder `entity-chip/` into the project's ui folder (`index.ts`, `entity-chip.tsx`, `EntityChip.vue`, `EntityChip.svelte`, `entity-chip.recipe.ts`), and what it is built from: [Avatar](/components/avatar.md). First time: [Installation](/installation.md).

## Usage

```tsx
import { EntityChip } from "@/components/ui/entity-chip";
```

```vue
import { EntityChip } from "@/components/ui/entity-chip";
```

```svelte
import { EntityChip } from "$lib/components/ui/entity-chip";
```

## Parts

In the DOM the root carries `data-slot="entity-chip"` and each part `data-slot="entity-chip-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `span` | `entity-chip` |  | Holds the monogram, our Avatar (16px, round, aria-hidden, initials only), then the name. Sets the avatar's default fill to the orange token |
| `name` | `span` | `entity-chip-name` |  | Truncates at the end; unicode-bidi: plaintext |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `name` | `string` |  |  |
| `color` | `string` |  | Any CSS color for the monogram (the avatar's color); defaults to the orange token. |
| `monogram` | `string` |  | Glyph in the disc; defaults to the first grapheme of the name, upper-cased (so emoji and accented letters survive). |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Keyboard and accessibility

Notes:

- The monogram (our avatar) is aria-hidden; the name is the text.
- The root's title exposes the full name when it is truncated.

## Tokens

`color.field`, `color.ink`, `color.orange`, `shadow.hairline`, `radius.pill`, `text.xs`

## Dependencies

- [Avatar](/components/avatar.md)

## Examples

### Activity feed

React · `activity-feed.tsx`

```tsx
import { EntityChip } from "@/components/ui/entity-chip";

const activity = [
  { id: 1, who: "Maya Chen", color: "var(--fndn-tag-orange)", action: "invited", target: "Priya Raman", targetColor: "var(--fndn-tag-purple)", when: "2 min ago" },
  { id: 2, who: "Daniel Okafor", color: "var(--fndn-tag-blue)", action: "deployed", target: "web-app", targetColor: "var(--fndn-tag-green)", when: "1 h ago" },
];

export default function ActivityFeed() {
  return (
    <ul className="flex w-80 flex-col gap-3 text-md text-ink">
      {activity.map((item) => (
        <li key={item.id}>
          <EntityChip name={item.who} color={item.color} /> {item.action} <EntityChip name={item.target} color={item.targetColor} /> <span className="text-sm text-ink-2">{item.when}</span>
        </li>
      ))}
    </ul>
  );
}
```

Vue · `activity-feed.vue`

```vue
<script setup lang="ts">
import { EntityChip } from "@/components/ui/entity-chip";

const activity = [
  { id: 1, who: "Maya Chen", color: "var(--fndn-tag-orange)", action: "invited", target: "Priya Raman", targetColor: "var(--fndn-tag-purple)", when: "2 min ago" },
  { id: 2, who: "Daniel Okafor", color: "var(--fndn-tag-blue)", action: "deployed", target: "web-app", targetColor: "var(--fndn-tag-green)", when: "1 h ago" },
];
</script>

<template>
  <ul class="flex w-80 flex-col gap-3 text-md text-ink">
    <li v-for="item in activity" :key="item.id">
      <EntityChip :name="item.who" :color="item.color" /> {{ item.action }} <EntityChip :name="item.target" :color="item.targetColor" /> <span class="text-sm text-ink-2">{{ item.when }}</span>
    </li>
  </ul>
</template>
```

Svelte · `activity-feed.svelte`

```svelte
<script lang="ts">
  import { EntityChip } from "$lib/components/ui/entity-chip";

  const activity = [
    { id: 1, who: "Maya Chen", color: "var(--fndn-tag-orange)", action: "invited", target: "Priya Raman", targetColor: "var(--fndn-tag-purple)", when: "2 min ago" },
    { id: 2, who: "Daniel Okafor", color: "var(--fndn-tag-blue)", action: "deployed", target: "web-app", targetColor: "var(--fndn-tag-green)", when: "1 h ago" },
  ];
</script>

<ul class="flex w-80 flex-col gap-3 text-md text-ink">
  {#each activity as item (item.id)}
    <li>
      <EntityChip name={item.who} color={item.color} /> {item.action} <EntityChip name={item.target} color={item.targetColor} /> <span class="text-sm text-ink-2">{item.when}</span>
    </li>
  {/each}
</ul>
```

### Projects in a status message

React · `paused-projects.tsx`

```tsx
import { EntityChip } from "@/components/ui/entity-chip";

/* one colour per project, the same everywhere it is named */
export default function PausedProjects() {
  return (
    <p className="max-w-[300px] text-md text-ink">
      Deploys are paused on <EntityChip name="billing-api" color="var(--fndn-tag-purple)" /> and <EntityChip name="data-pipeline" color="var(--fndn-tag-cyan)" /> until the incident is resolved.
    </p>
  );
}
```

Vue · `paused-projects.vue`

```vue
<script setup lang="ts">
import { EntityChip } from "@/components/ui/entity-chip";
</script>

<!-- one colour per project, the same everywhere it is named -->
<template>
  <p class="max-w-[300px] text-md text-ink">
    Deploys are paused on <EntityChip name="billing-api" color="var(--fndn-tag-purple)" /> and <EntityChip name="data-pipeline" color="var(--fndn-tag-cyan)" /> until the incident is resolved.
  </p>
</template>
```

Svelte · `paused-projects.svelte`

```svelte
<script lang="ts">
  import { EntityChip } from "$lib/components/ui/entity-chip";
</script>

<!-- one colour per project, the same everywhere it is named -->
<p class="max-w-[300px] text-md text-ink">
  Deploys are paused on <EntityChip name="billing-api" color="var(--fndn-tag-purple)" /> and <EntityChip name="data-pipeline" color="var(--fndn-tag-cyan)" /> until the incident is resolved.
</p>
```

### Channel with a custom monogram

React · `alert-channel.tsx`

```tsx
import { EntityChip } from "@/components/ui/entity-chip";

/* a custom monogram when the first letter says nothing: a channel */
export default function AlertChannel() {
  return (
    <p className="max-w-[300px] text-md text-ink">
      Failed deploys post to <EntityChip name="deploys" monogram="#" color="var(--fndn-tag-green)" /> and page <EntityChip name="Jonas Weber" color="var(--fndn-tag-blue)" /> after 10 minutes.
    </p>
  );
}
```

Vue · `alert-channel.vue`

```vue
<script setup lang="ts">
import { EntityChip } from "@/components/ui/entity-chip";
</script>

<!-- a custom monogram when the first letter says nothing: a channel -->
<template>
  <p class="max-w-[300px] text-md text-ink">
    Failed deploys post to <EntityChip name="deploys" monogram="#" color="var(--fndn-tag-green)" /> and page <EntityChip name="Jonas Weber" color="var(--fndn-tag-blue)" /> after 10 minutes.
  </p>
</template>
```

Svelte · `alert-channel.svelte`

```svelte
<script lang="ts">
  import { EntityChip } from "$lib/components/ui/entity-chip";
</script>

<!-- a custom monogram when the first letter says nothing: a channel -->
<p class="max-w-[300px] text-md text-ink">
  Failed deploys post to <EntityChip name="deploys" monogram="#" color="var(--fndn-tag-green)" /> and page <EntityChip name="Jonas Weber" color="var(--fndn-tag-blue)" /> after 10 minutes.
</p>
```

### Owner column in a table

React · `owners-table.tsx`

```tsx
import { EntityChip } from "@/components/ui/entity-chip";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const projects = [
  { name: "web-app", owner: "Maya Chen", color: "var(--fndn-tag-orange)", deploys: "1,284" },
  { name: "billing-api", owner: "Daniel Okafor", color: "var(--fndn-tag-blue)", deploys: "214" },
  { name: "data-pipeline", owner: "Sofia Alvarez", color: "var(--fndn-tag-pink)", deploys: "57" },
];

export default function OwnersTable() {
  return (
    <Table aria-label="Projects" className="w-[400px] max-w-full">
      <TableHeader>
        <TableRow>
          <TableHead>Project</TableHead>
          <TableHead>Owner</TableHead>
          <TableHead numeric>Deploys</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {projects.map((project) => (
          <TableRow key={project.name}>
            <TableCell>{project.name}</TableCell>
            <TableCell><EntityChip name={project.owner} color={project.color} /></TableCell>
            <TableCell numeric>{project.deploys}</TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}
```

Vue · `owners-table.vue`

```vue
<script setup lang="ts">
import { EntityChip } from "@/components/ui/entity-chip";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const projects = [
  { name: "web-app", owner: "Maya Chen", color: "var(--fndn-tag-orange)", deploys: "1,284" },
  { name: "billing-api", owner: "Daniel Okafor", color: "var(--fndn-tag-blue)", deploys: "214" },
  { name: "data-pipeline", owner: "Sofia Alvarez", color: "var(--fndn-tag-pink)", deploys: "57" },
];
</script>

<template>
  <Table aria-label="Projects" class="w-[400px] max-w-full">
    <TableHeader>
      <TableRow>
        <TableHead>Project</TableHead>
        <TableHead>Owner</TableHead>
        <TableHead numeric>Deploys</TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow v-for="project in projects" :key="project.name">
        <TableCell>{{ project.name }}</TableCell>
        <TableCell><EntityChip :name="project.owner" :color="project.color" /></TableCell>
        <TableCell numeric>{{ project.deploys }}</TableCell>
      </TableRow>
    </TableBody>
  </Table>
</template>
```

Svelte · `owners-table.svelte`

```svelte
<script lang="ts">
  import { EntityChip } from "$lib/components/ui/entity-chip";
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "$lib/components/ui/table";

  const projects = [
    { name: "web-app", owner: "Maya Chen", color: "var(--fndn-tag-orange)", deploys: "1,284" },
    { name: "billing-api", owner: "Daniel Okafor", color: "var(--fndn-tag-blue)", deploys: "214" },
    { name: "data-pipeline", owner: "Sofia Alvarez", color: "var(--fndn-tag-pink)", deploys: "57" },
  ];
</script>

<Table aria-label="Projects" class="w-[400px] max-w-full">
  <TableHeader>
    <TableRow>
      <TableHead>Project</TableHead>
      <TableHead>Owner</TableHead>
      <TableHead numeric>Deploys</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    {#each projects as project (project.name)}
      <TableRow>
        <TableCell>{project.name}</TableCell>
        <TableCell><EntityChip name={project.owner} color={project.color} /></TableCell>
        <TableCell numeric>{project.deploys}</TableCell>
      </TableRow>
    {/each}
  </TableBody>
</Table>
```

## Recipe

`entity-chip.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* entity-chip — monogram (our avatar, 16px, round, aria-hidden) + name in a soft field pill.
 * Names a supplier, person or record inside running text. Softer than a status pill, not a mono
 * token (see chip). A name longer than the container truncates at the end; the root carries it as
 * a title. The chip's default avatar fill is orange (--fndn-avatar-color, which the adapter's
 * `color` replaces on the avatar itself).
 *
 * No motion. The avatar is the real Avatar. */

export const entityChip = tv({
  slots: {
    base: [
      /* the inline margins stay inside the container */
      "inline-flex shrink-0 items-center gap-1 max-w-[calc(100%-4px)] mx-0.5 py-px ps-[3px] pe-1.5",
      "rounded-pill bg-field shadow-hairline align-middle whitespace-nowrap [--fndn-avatar-color:var(--fndn-orange)]",
    ],
    /* a name or signed value reads in its own direction on either page ("-4.41%" stays "-4.41%") */
    name: "min-w-0 overflow-hidden text-ellipsis text-xs font-medium leading-[1.5] text-ink [unicode-bidi:plaintext]",
  },
});

export type EntityChipRecipeProps = VariantProps<typeof entityChip>;
```
