# Avatar

Someone's picture: a person's portrait or initials, an agent's character or photo with its state, or the mail glyph of someone outside Arcadia, with one mark when they can be reached.

Live variants: https://design.arcadia.is/components/avatar

```tsx
import {
  Avatar, AvatarStack, AgentAvatarPicker, AgentRing, characterFromId,
  staticAvatarSvg, staticPictureAvatarSvg,
} from "@arcadia/ui";
```

## When to use

- A person's picture in a row, a list or a profile head, with their initials while it loads or when it fails
- An agent's character or photo, its state in the character's face or in the ring round the photo
- Someone outside Arcadia, such as a mail's sender, by the mail glyph
- Who can be reached now, one steady mark on their picture
- A team without a picture of its own, its initials among teams
- People and agents together where room is short (`AvatarStack`), and an agent's character picked from the fifteen (`AgentAvatarPicker`)

## When not to use

- A team named as one kind among others: use `Icon`
- A mark such as unread on an agent's character: set a `StatusDot` beside the avatar
- Who did something, in words: use `ActorName` beside the picture

## In context

In Act, the list that @ opens shows each person's picture beside their name, and a list of agents sets each character beside its name, its state in the face and in words.

```tsx
import {
  Avatar, Card, CardHeader, CardRows, CardTitle, ListRow,
} from "@arcadia/ui";

<Card>
  <CardHeader><CardTitle>Members</CardTitle></CardHeader>
  <CardRows>
    {/* 24px: two initials each; a broken image falls back to the same tinted monogram */}
    <ListRow leading={<Avatar name="Maya Tran" size={24} />} label="Maya Tran" meta="Owner" interactive={false} />
    <ListRow leading={<Avatar name="Ada Lovelace" size={24} />} label="Ada Lovelace" meta="Editor" interactive={false} />
    <ListRow leading={<Avatar name="Grace Hopper" picture={BROKEN} size={24} />} label="Grace Hopper" meta="Viewer" interactive={false} />
  </CardRows>
</Card>
```

```tsx
import { Avatar, ListRow } from "@arcadia/ui";

<div {...sx("cmp-rows", cmp.rows)}>
  <ListRow leading={<Avatar kind="agent" avatar={JUNIPER} name="Juniper" size="text" state="working" />} label="Juniper" meta="Working" active />
  <ListRow leading={<Avatar kind="agent" avatar={PEBBLE} name="Pebble" size={20} />} label="Pebble" />
  <ListRow leading={<Avatar kind="agent" avatar={ATLAS} name="Atlas" state="waiting" size={20} />} label="Atlas" meta="Waits for your answer" />
  <ListRow leading={<Avatar kind="agent" avatar={EMBER} name="Ember" state="sleeping" size={20} />} label="Ember" meta="Paused" />
</div>
```

## Usage

```tsx
import { Avatar } from "@arcadia/ui";

<Avatar name="Ada Lovelace" picture="/avatars/ada.png" size={24} />
<Avatar kind="agent" avatar={agent.avatar} name={agent.name} stateLabel={agent.stateWords} size={20} state={agent.state} />
<Avatar {...actor} />
```

`kind` says who the picture stands for: a person (the default) by `name` and `picture`, an agent (`kind="agent"`) by its `name`, its stored `avatar` and the `person` it acts for, and someone outside Arcadia (`kind="outside"`) by the `address` their mail came from. These are the fields of an `Actor`, so spreading an actor into `Avatar` draws whoever acts.

Without an image an avatar is a monogram: the first letter of the first and the last word of the name, one letter at 20 and under. Its tone is hashed from the name, one of blue, cyan, green, purple and pink, so a person keeps the same colour everywhere; never the beacon, yellow or red, which mean something else. The monogram also shows until an image has loaded, after a 300ms grace period so a fast image never flashes a letter first, and it stays if the image fails: Grace's image above is broken, and the row keeps its shape and colour.

Give a person's moving picture a still `picture` and a separate `motionSrc`. Set `playMotion` to `visible` in a profile head or an open hover card, or to `intent` for a picture at 32 or larger, which plays while the pointer is on it or it has the focus. Otherwise it stays still. Under reduced motion the moving file is never requested, and the monogram shows if either file fails. An agent's picture plays from its `state` instead.

## Examples

### People and agents

The frame follows who the picture stands for, never whether an image loaded: a person's circle, and an agent's rounded square in the kit's corner for its size, 6 up to 24, 8 from 28 to 40, 12 from 48, with a hairline over photo and monogram alike. The frame takes no more room in a row than the circle.

Identity and size

Rows: 20, 24, 32, 40, 48. Columns: Person, photo, Person, initials, Agent, photo, Agent, initials.

### Someone outside

`kind="outside"` draws the mail glyph, never a face or initials, so nobody takes it for an account here. It is named by the `address` and, before it, the `name` their server gave, if any.

```tsx
import { Avatar } from "@arcadia/ui";

<Avatar kind="outside" address="billing@supplier.example" size={16} />
<Avatar kind="outside" address="billing@supplier.example" size={20} />
<Avatar kind="outside" name="Grace Hopper" address="grace.hopper.1906@navy-archive.example" />
```

### An agent and its person

With `person`, an agent's picture has its person's beside it a step smaller: 16 beside 20, 12 beside 16. Where words beside it name the person (a message's author line, Members, the list that @ opens), `alone` draws the agent's own picture, so the person is said once.

```tsx
import { Avatar } from "@arcadia/ui";

<Avatar {...ada} size={20} />
<Avatar {...scout} size={20} />
<Avatar {...scout} alone size={20} />
<Avatar {...ada} size={16} />
<Avatar {...scout} size={16} />
<Avatar {...scout} size={16} alone />
```

### Sizes

16, 20, 24, 28 (the default), 32, 36, 40, 48, 56, 64, 72 and 96, for a person and an agent alike. 20 to 40 are the control heights; use 36 in a person row and 64 in a profile head. A monogram grows a text style with its size.

```tsx
import { Avatar } from "@arcadia/ui";

<Avatar name="Maya Tran" size={20} />
<Avatar name="Maya Tran" size={24} />
<Avatar name="Maya Tran" />
<Avatar name="Maya Tran" size={32} />
<Avatar name="Maya Tran" size={40} />
<Avatar name="Maya Tran" size={48} />
<Avatar name="Maya Tran" size={64} />
<Avatar name="Maya Tran" size={96} />
```

```tsx
import { Avatar } from "@arcadia/ui";

{([16, 20, 24, 28, 32, 36, 48, 56, 64, 72, 96] as const).map(size => <Avatar kind="agent" key={size} avatar={ATLAS} name="Atlas" size={size} />)}
```

### At the line height

`size="text"` follows the line, not the glyph box: 20px in a Body row, 22px in Headline and 16px in Caption. It shows one initial and no presence dot.

```tsx
import { Avatar, Icon, ListRow } from "@arcadia/ui";

<div {...sx("cmp-rows", cmp.rows, page.members)}>
  <ListRow interactive={false} leading={<Avatar name="Ada Lovelace" size="text" />} label="Ada asked for a review" />
  <ListRow interactive={false} leading={<Icon name="branch" />} label="Opened a branch" />
</div>
```

### A picture on its own

From 40 up the dot is the large one, 10px, so it reads beside a picture without growing into a badge.

```tsx
import { Avatar } from "@arcadia/ui";

<Avatar name="Ada Lovelace" size={48} presence="online" />
<Avatar name="Ada Lovelace" picture={SAMPLE_IMAGE} size={64} presence="busy" />
<Avatar name="Ada Lovelace" size={96} presence="online" />
```

### A team

A team has no picture of its own. Where teams stand among teams, each is the monogram of its name, which tells one from the next.

```tsx
import { Avatar, ListRow } from "@arcadia/ui";

<Cell caption="Among teams: each its initials">
  <div {...sx("cmp-rows", cmp.rows, page.members)}>
    <ListRow interactive={false} leading={<Avatar name="Acme" size="text" />} label="Acme" />
    <ListRow interactive={false} leading={<Avatar name="Kestrel Labs" size="text" />} label="Kestrel Labs" />
    <ListRow interactive={false} leading={<Avatar name="Orchard" size="text" />} label="Orchard" />
  </div>
</Cell>
<Cell caption="One kind among others: the glyph">
  <div {...sx("cmp-rows", cmp.rows, page.members)}>
    <ListRow interactive={false} leading="account" label="Account" />
    <ListRow interactive={false} leading="team" label="Teams" />
    <ListRow interactive={false} leading="laptop" label="Devices" />
  </div>
</Cell>
```

- Among teams: each its initials
- One kind among others: the glyph

The list of a person's teams, the invitations to them and a team's own head take the monogram. Where a team is named as one kind among others, a row of a nav, a row beside people and agents, or an empty list of teams, it takes the `team` glyph: a monogram there would read as a person.

| Token | Value |
| --- | --- |
| `--avatar-36` |  |
| `--avatar-48` |  |
| `--avatar-56` |  |
| `--avatar-64` |  |
| `--avatar-72` |  |
| `--avatar-96` |  |

## Agents

An agent is one of fifteen characters: a circle, a square, a triangle, a pillow, a cloud, a drop, a starfish, a heart, a clover, a flower, a ghost, a mushroom, a cactus, an acorn and a light bulb, each in its own colour for either theme, or in one of eight body hues a person picks (`hue`; without it, its own colour). Its face is two brows and nothing else, which a person reads as eyes. Store the picked fields, not the seed: a later change to the lists never re-skins an agent. `characterFromId` draws the same character for the same id every time.

Every face is drawn the same size: each character sits in a tile 4.2 of its face's radii square, centred on its body. The brows are one round stroke, 0.78 by 0.27 of that radius, white, or a dark ink on a body too light for white (under 2.2:1). While an agent works, its character turns all the way round now and then. Only the 12 most recently active working faces in view move. The others show their still pose.

A photo fills the frame and is the face: nothing is drawn on it, and its state is the ring round it, in the frame's corner. While the photo loads, the frame shows a skeleton or a previously loaded thumbnail passed as `placeholderSrc`. The character appears if the photo fails to load. `photoSrc` is the still poster and `motionSrc` the animated WebP, under the same 12-face limit as characters. A failure of either file shows the stored character. Without `avatar`, the agent's monogram stands in its frame.

### Fifteen characters, six states

Idle, working (the gaze reads left and right, and now and then the whole body turns all the way round), waiting (one brow raised), sleeping (thin brows, eyes down), done and error. Only the working face moves. Under reduced motion each holds the pose shown here.

```tsx
import { AGENT_AVATAR_STATES, AGENT_SHAPES, Avatar } from "@arcadia/ui";

<div id="agent-avatar-grid" role="group" aria-label="The fifteen characters in the six states" {...sx("cmp-agent-grid", styles.grid)}>
  <span {...sx("cmp-agent-grid-legend", styles.legend)}>Left to right: {AGENT_AVATAR_STATES.join(", ")}</span>
  <span {...sx("cmp-agent-grid-head", styles.head)} />
  {AGENT_AVATAR_STATES.map((s) => <span key={s} {...sx("cmp-agent-grid-head", styles.head)}>{word(s)}</span>)}
  {AGENT_SHAPES.map((shape) => [
    <span key={shape} {...sx("cmp-agent-grid-name", styles.name)}>{word(shape)}</span>,
    ...AGENT_AVATAR_STATES.map((s) => (
      <Avatar kind="agent" key={`${shape}-${s}`} avatar={{ ...JUNIPER, shape }} name={word(shape)} stateLabel={STATE_WORDS[s]} size={28} state={s} />
    )),
  ])}
</div>
```

### Every character in its frame

Each of the fifteen sits in the frame over a well, inset 8% so no silhouette, ear or lean is cropped, and a whole turn passes outside the frame rather than being clipped. The frame keeps its corner at every row size.

Character and size

Rows: 16, 20, 24, 32, 36, 48. Columns: Circle, Square, Triangle, Squircle, Cloud, Teardrop, Star, Heart, Clover, Flower, Ghost, Mushroom, Cactus, Acorn, Lightbulb.

### A turn

`poke` hops a moving character on a press, where a press means nothing else. Pass `activityAt` in Unix milliseconds to rank working faces by their latest activity. Otherwise the kit uses when each face started showing work. No face moves in a hidden tab.

```tsx
import { useState } from "react";
import { AGENT_AVATAR_STATES, Avatar, Button } from "@arcadia/ui";

function Turn() {
  const [state, setState] = useState<AgentAvatarState>("working");
  return (
    <>
      <Avatar kind="agent" id="agent-avatar-turn" avatar={JUNIPER} name="Juniper" stateLabel={STATE_WORDS[state]} size={96} state={state} poke />
      {AGENT_AVATAR_STATES.map((s) => (
        <Button key={s} variant="secondary" size="sm" aria-pressed={state === s} onClick={() => setState(s)}>{word(s)}</Button>
      ))}
    </>
  );
}
```

### Ready in its chat

`ready` shows a still face looking out while the agent is idle and its chat is open. Every other state keeps its own pose.

```tsx
import { useState } from "react";
import { Avatar, Button } from "@arcadia/ui";

function Ready() {
  const [opened, setOpened] = useState(0);
  return (
    <>
      <Avatar kind="agent" key={opened} id="agent-avatar-ready" avatar={JUNIPER} name="Juniper" size={72} ready />
      <Button variant="secondary" size="sm" onClick={() => setOpened((n) => n + 1)}>Open the chat again</Button>
    </>
  );
}
```

### A picture's ring

Idle and sleeping: no ring. Working: the neutral running ring, its arc travelling once round the frame outline each 1.9s, corners and all. Waiting, done and error: one ring in the accent, the three alike, so `stateLabel` says which.

```tsx
import { AGENT_AVATAR_STATES, Avatar } from "@arcadia/ui";

function PictureRings() {
  const photo = { kind: "photo", sha: "fixture", character: JUNIPER } as const;
  return (
    <div id="agent-picture-rings" {...sx("cmp-agent-rings", styles.row)}>
      {AGENT_AVATAR_STATES.map((s) => (
        <Avatar kind="agent" key={s} avatar={photo} photoSrc={PORTRAIT_ILLUSTRATION} name="Juniper" stateLabel={STATE_WORDS[s]} size={48} state={s} />
      ))}
    </div>
  );
}
```

### A picture in a row

The working ring from a sidebar row to a profile head. The frame corner is roundest where the avatar is smallest, and the arc follows that outline, straight edges and corners, so it never crosses the picture or swings past the frame.

```tsx
import { Avatar } from "@arcadia/ui";

function PictureSizes() {
  const photo = { kind: "photo", sha: "fixture", character: JUNIPER } as const;
  return (
    <div id="agent-picture-sizes" {...sx("cmp-agent-ring-sizes", styles.row)}>
      {([16, 20, 24, 28, 32, 48, 64] as const).map(size => (
        <Avatar kind="agent" key={size} avatar={photo} photoSrc={PORTRAIT_ILLUSTRATION} name="Juniper" stateLabel={STATE_WORDS.working} size={size} state="working" />
      ))}
    </div>
  );
}
```

### In a rounded frame

A picture in a frame marked with `nest.pictureFrame` takes the frame's corner less its pad: square at 12 in a frame of 12, 4 at 8, 8 at 4, so the two corners stay concentric.

```tsx
import { Avatar } from "@arcadia/ui";

function InAFrame() {
  const photo = { kind: "photo", sha: "fixture", character: JUNIPER } as const;
  const frames = [{ pad: pads.pad12, inset: 12, corner: 0 }, { pad: pads.pad8, inset: 8, corner: 4 }, { pad: pads.pad4, inset: 4, corner: 8 }] as const;
  return (
    <div id="agent-picture-frame" {...sx("cmp-agent-frames", styles.frames)}>
      {frames.map(({ pad, inset, corner }) => (
        <div key={inset} {...sx("cmp-agent-frame", styles.frameColumn)}>
          <div {...sx("cmp-agent-frame-box", styles.frameBox, pad)}>
            <Avatar kind="agent" avatar={photo} photoSrc={PORTRAIT_ILLUSTRATION} name="Juniper" size={48} />
          </div>
          <span {...sx("cmp-agent-frame-note", styles.frameNote)}>{`pad ${inset}, corner ${corner}`}</span>
        </div>
      ))}
    </div>
  );
}
```

A product marks the frame it draws itself with `nest.pictureFrame(radius["--radius-frame"], pad)` on its own row or pinned tile, and passes the picture no radius. A card, a dialog or a popover ends the mark, so a picture standing in one keeps the step its size names.

### In a card and in a dialog

Both frames are unmarked, so the picture keeps the step its size names: 12 at 48, whatever the frame's corner and pad.

```tsx
import {
  Avatar, Card, CardBody, Dialog, DialogBody, DialogContent,
} from "@arcadia/ui";

function InASurface({ container }: { container?: HTMLElement }) {
  const photo = { kind: "photo", sha: "fixture", character: JUNIPER } as const;
  const face = (
    <span {...sx("cmp-avatar-face", styles.face)}>
      <Avatar kind="agent" avatar={photo} photoSrc={PORTRAIT_ILLUSTRATION} name="Juniper" size={48} />
      <span {...sx("cmp-avatar-face-name", styles.faceName)}>Juniper</span>
    </span>
  );
  if (container == null) return <Card><CardBody>{face}</CardBody></Card>;
  return (
    <Dialog open modal={false} disablePointerDismissal>
      <DialogContent container={container} initialFocus={false}>
        <DialogBody>{face}</DialogBody>
      </DialogContent>
    </Dialog>
  );
}
```

### A moving portrait

Only work makes the portrait play. Waiting for you and other inactive states show the poster. Under reduced motion, the working row holds that same poster.

```tsx
import { useState } from "react";
import { Avatar, Button, ListRow } from "@arcadia/ui";

function MovingPortraits() {
  const [working, setWorking] = useState(true);
  const photo = { kind: "photo", sha: "fixture", character: JUNIPER } as const;
  return (
    <div {...sx("cmp-rows", cmp.rows)} id="moving-portrait-specimen">
      <ListRow size="person" leading={<Avatar kind="agent" avatar={photo} name="Juniper" size={36} state={working ? "working" : "idle"}
        photoSrc={PORTRAIT_POSTER} motionSrc={PORTRAIT_MOTION} aria-hidden />}
        label="Juniper" meta={working ? "Working" : "Idle"} interactive={false} />
      <ListRow size="person" leading={<Avatar kind="agent" avatar={photo} name="Pebble" size={36} state="idle"
        photoSrc={PORTRAIT_POSTER} motionSrc={PORTRAIT_MOTION} aria-hidden />} label="Pebble" meta="Idle poster" interactive={false} />
      <ListRow size="person" leading={<Avatar kind="agent" avatar={{ ...photo, character: ATLAS }} name="Atlas" size={36} state="working"
        photoSrc={PORTRAIT_BROKEN} motionSrc={PORTRAIT_MOTION} aria-hidden />} label="Atlas" meta="Photo unavailable" interactive={false} />
      <ListRow size="person" leading={<Avatar kind="agent" avatar={photo} name="Ember" size={36} state={working ? "working" : "idle"}
        photoSrc={PORTRAIT_POSTER} motionSrc={PORTRAIT_BROKEN} aria-hidden />} label="Ember" meta="Still photo" interactive={false} />
      <Button variant="secondary" size="sm" onClick={() => setWorking(value => !value)}>{working ? "Stop work" : "Start work"}</Button>
    </div>
  );
}
```

### Nothing on a character

A character draws no mark on its corners: `presence="online"` only adds ", online" to its name, and `badge` draws nothing. Where a product wants a mark, it sets it beside the avatar, as here.

```tsx
import { Avatar, StatusDot } from "@arcadia/ui";

<div {...sx("cmp-agent-beside", styles.row)}>
  <span {...sx("cmp-agent-pair", styles.pair)}>
    <Avatar kind="agent" avatar={PEBBLE} name="Pebble" stateLabel="finished while you were away" size={28} state="done" />
    <StatusDot status="unread" label="Unread" />
  </span>
  <span {...sx("cmp-agent-pair", styles.pair)}>
    <Avatar kind="agent" avatar={ATLAS} name="Atlas" size={28} presence="online" />
    <StatusDot tone="success" label="Online" />
  </span>
</div>
```

### Brow spacing

One spacing and resting gaze for every character (`FACE_GEOMETRY`): the first row. The rows under it are other spacings, drawn to compare.

```tsx
import { staticAvatarSvg } from "@arcadia/ui";

<div id="agent-brow-spacings" {...sx("cmp-agent-grid", styles.spacings)}>
  <span />
  {(["circle", "heart", "lightbulb"] as const).flatMap((shape) => (["idle", "waiting"] as const).map((s) => (
    <span key={`${shape}-${s}`} {...sx("cmp-agent-grid-head", styles.head)}>{`${word(shape)}, ${s}`}</span>
  )))}
  {SPACINGS.map(([label, geometry]) => [
    <span key={label} {...sx("cmp-agent-grid-name", styles.name)}>{label}</span>,
    ...(["circle", "heart", "lightbulb"] as const).flatMap((shape) => (["idle", "waiting"] as const).map((s) => (
      <img key={`${label}-${shape}-${s}`} {...sx("cmp-agent-still", styles.still)} alt={`${word(shape)}, ${s}, ${label}`}
        src={`data:image/svg+xml,${encodeURIComponent(staticAvatarSvg({ shape, state: s, theme: "dark", size: 48, geometry }))}`} />
    ))),
  ])}
</div>
```

### Static images

`staticAvatarSvg` draws one frozen face per state as a standalone file: colours written out, no script, no outside reference, a title. The design site publishes all 180 under /agent-avatars/. `staticPictureAvatarSvg` freezes a picture's ring and, by default, never carries the picture: the last two of each row are a picture's files, the character in its place. One file per theme, night above, day below.

```tsx
import {
  AGENT_AVATAR_STATES, staticAvatarSvg, staticPictureAvatarSvg,
} from "@arcadia/ui";

<div {...sx("cmp-agent-static", styles.statics)}>
  {(["dark", "light"] as const).map((theme) => (
    <div key={theme} {...sx("cmp-agent-static-row", styles.row)}>
      {AGENT_AVATAR_STATES.map((s) => (
        <img key={s} {...sx("cmp-agent-still", styles.still)} alt={`Juniper, ${STATE_WORDS[s]}, ${theme}`}
          src={`data:image/svg+xml,${encodeURIComponent(staticAvatarSvg({ shape: JUNIPER.shape, state: s, theme, size: 48, title: `Juniper, ${STATE_WORDS[s]}` }))}`} />
      ))}
      {(["working", "waiting"] as const).map((s) => (
        <img key={`p-${s}`} {...sx("cmp-agent-still", styles.still)} alt={`Juniper's picture left out, ${STATE_WORDS[s]}, ${theme}`}
          src={`data:image/svg+xml,${encodeURIComponent(staticPictureAvatarSvg({ state: s, theme, character: JUNIPER, title: `Juniper, ${STATE_WORDS[s]}` }))}`} />
      ))}
    </div>
  ))}
</div>
```

## Presence

Whether someone can be reached now, and nothing else: `presence` draws one steady mark on the avatar's bottom end corner, parted from the picture by a ring of whatever surface it stands on. Offline and unknown draw nothing.

Online is a dot in the success tone. Busy, here and asked not to be interrupted, is the same dot in the quiet ink with a bar of the ground across it, the sign for do not disturb: the two differ by their shape, so neither is told by its colour alone.

### Every size, on two surfaces

Offline, online, then busy: the mark stays inside the avatar's box, so a row, a stack or a pair of avatars takes the same room either way. 6px on 20 and 24, 8px on 28 and 32, 10px from 40.

```tsx
import { Avatar } from "@arcadia/ui";

function Online() {
  const sizes: AvatarSize[] = [20, 24, 28, 32, 40];
  return (
    <div {...sx("avatar-sizes", page.sizes)}>
      {sizes.map((size) => <Avatar key={`off-${size}`} name="Ada Lovelace" size={size} presence="offline" />)}
      {sizes.map((size) => <Avatar key={`on-${size}`} name="Ada Lovelace" picture={SAMPLE_IMAGE} size={size} presence="online" />)}
      {sizes.map((size) => <Avatar key={`busy-${size}`} name="Ada Lovelace" size={size} presence="busy" />)}
    </div>
  );
}
```

- On the ground
- On a raised panel

### A badge on the corner

`badge` holds a 14px mark (a `StatusDot`, a `ProviderMark`) on the bottom end corner, in place of the presence dot. Its centre stands on the corner's arc at every size, a circle's or an agent's frame's, the place worked out from the avatar's corner, and the picture is cut round it by the presence ring's width. Its words go in the avatar's `aria-label`.

```tsx
import { Avatar, StatusDot } from "@arcadia/ui";

function Badged() {
  const sizes: AvatarSize[] = [28, 32, 40, 48];
  return (
    <div {...sx("avatar-sizes", page.sizes)}>
      {sizes.map((size) => <Avatar key={`p-${size}`} name="Ada Lovelace" size={size} badge={<StatusDot status="done" label="Connected" />} aria-label="Ada Lovelace, connected" />)}
      {sizes.map((size) => <Avatar key={`a-${size}`} kind="agent" name="Atlas" size={size} badge={<StatusDot status="error" label="Signed out" />} aria-label="Atlas, signed out" />)}
    </div>
  );
}
```

### Beside a green monogram

The ring keeps the dot apart from a fill of a like hue.

```tsx
import { Avatar } from "@arcadia/ui";

<Avatar name="Ada Lovelace" hue="green" size={28} presence="online" />
<Avatar name="Ada Lovelace" hue="green" size={32} presence="online" />
<Avatar name="Ada Lovelace" hue="green" size={40} presence="online" />
```

### Offline in words

Where a row has a quiet second line, it says what the dot cannot: an offline agent reads when it went, with no dot of its own. Online and busy need no word, and unknown gets none.

```tsx
import { Avatar, ListRow } from "@arcadia/ui";

<div {...sx("cmp-rows", cmp.rows, page.members)}>
  <ListRow size="person" interactive={false} leading={<Avatar name="Ada Lovelace" size={32} presence="online" />} label="Ada Lovelace" />
  <ListRow size="person" interactive={false} leading={<Avatar name="Grace Hopper" size={32} presence="busy" />} label="Grace Hopper" />
  <ListRow size="person" interactive={false} leading={<Avatar kind="agent" avatar={SCOUT} name="Scout" size={36} />} label="Scout" sub="Offline since 14:02" />
  <ListRow size="person" interactive={false} leading={<Avatar kind="agent" avatar={WREN} name="Wren" size={36} presence="online" />} label="Wren" />
</div>
```

### A change

A swap in place over the fast duration: the mark and its ring fade in or out together, and between online and busy the ink moves on the beat while the bar comes at once.

```tsx
import { useState } from "react";
import { Avatar, SegmentedControl } from "@arcadia/ui";

function Swap() {
  const [presence, setPresence] = useState<Presence>("online");
  return (
    <>
      <Avatar name="Ada Lovelace" size={40} presence={presence} />
      <SegmentedControl aria-label="Presence" value={presence} onValueChange={(v) => setPresence(v as Presence)}
        items={[{ value: "online", label: "Online" }, { value: "busy", label: "Busy" }, { value: "offline", label: "Offline" }]} />
    </>
  );
}
```

Show it only where someone is chosen to be addressed, the list that @ opens, a picker of who gets something, a team's members, and on the person's own picture in their bar, where they set it. Never on a board's cards, never on the author of a message already sent. Pass `presence` to the avatar itself; a `StatusDot` is never laid onto one. It goes on the agent's own picture and never on its person's beside it, and an agent is never busy: its own state is its product's to show. Under 20, and for someone `removed`, it draws nothing. It never pops, pulses or glows, and under reduced motion it changes in one frame.

| Token | Use | Value |
| --- | --- | --- |
| `--status-online` | Online's dot: the success tone, the one a `StatusDot` with `tone="success"` draws. |  |
| `--status-busy` | Busy's dot, a bar of the ground across it: the quiet ink, so the shape says it and the ink stays calm. |  |
| `--presence-dot-sm` | The dot on an avatar of 20 and 24. |  |
| `--presence-dot-md` | On 28 to 36. |  |
| `--presence-dot-lg` | On 40 and up. |  |
| `--presence-ring` | The ring of the surface between the dot and the picture: one step past a hairline. |  |

## Stack

`AvatarStack` overlaps a few people and agents on discs of the surface colour, with the rest folded into a count. Agents take their picture sources and state; people take their picture or initial, with no presence dot.

```tsx
import { AvatarStack } from "@arcadia/ui";

function Stack() {
  const team: AvatarStackItem[] = [
    { kind: "agent", id: "a", name: "Juniper", avatar: JUNIPER }, { kind: "agent", id: "b", name: "Pebble", avatar: PEBBLE },
    { kind: "agent", id: "c", name: "Atlas", avatar: ATLAS }, { kind: "agent", id: "d", name: "Ember", avatar: EMBER },
  ];
  const mixed: AvatarStackItem[] = [
    { kind: "person", id: "p", name: "Ada" },
    ...team.slice(0, 2),
  ];
  return (
    <>
      <AvatarStack items={team.slice(0, 2)} label="Agents on act" />
      <AvatarStack items={mixed} label="People and agents on act" />
      <AvatarStack items={[...team, { kind: "person", id: "p", name: "Ada" }, { kind: "person", id: "m", name: "Maya" }]} label="People and agents on act" />
      <AvatarStack items={team} size={24} max={4} label="Agents on act" />
    </>
  );
}
```

### Stack sizes

16, the default, 20 and 24: a person keeps the circle and an agent its frame.

- 16
- 20
- 24

## Picker

`AgentAvatarPicker` sets the fifteen as one radio group and the eight body hues as a second: one tab stop each, the arrow keys move, the picked one checked. A pick hands back the whole record with only the shape or the hue changed; write it at once. A hue a shape already wears draws its own colour. `onUpload` adds Upload photo, or Change photo when there is one.

```tsx
import { useState } from "react";
import { AgentAvatarPicker, Avatar, shuffledCharacter } from "@arcadia/ui";

function Picker() {
  const [value, setValue] = useState<CharacterAvatar>(JUNIPER);
  const [photo, setPhoto] = useState(false);
  return (
    <div {...sx("cmp-agent-editor", styles.editor)}>
      <Avatar kind="agent" avatar={value} name="Juniper" size={64} />
      <AgentAvatarPicker id="agent-avatar-picker" name="Juniper" value={value} onChange={setValue}
        onShuffle={() => setValue(shuffledCharacter(value.color))} onReset={() => setValue(JUNIPER)}
        onUpload={() => setPhoto(true)} hasPhoto={photo} onRemovePhoto={() => setPhoto(false)} />
    </div>
  );
}
```

## Stored shapes

A record from before the fifteen reads through one pure mapping: nothing is rewritten, and a shape off every list falls back to the one the agent's id draws.

| Stored | Reads as |
| --- | --- |
| blob | circle |
| pebble | circle |
| tablet | square |
| hex | squircle |
| wedge | triangle |
| house | square |
| sparkle | star |
| moon | circle |
| duck | circle |

## Matrix

Size and source

Rows: 20, 24, 28, 32, 40, 48, 64, 96, Text. Columns: Monogram, Image, Broken image.

Size and presence

Rows: 20, 24, 28, 32, 40, 48, 64, 96, Text. Columns: Unknown, Offline, Online, Busy.

Hue

Rows: 28. Columns: Blue, Cyan, Green, Purple, Pink, Neutral.

Size and state

Rows: 16, 28, 48. Columns: Idle, Working, Waiting, Sleeping, Done, Error.

## Customising

`hue` picks a tone instead of the hash (`neutral` is the quiet grey). `rootStyle` takes layout and these knobs: a size, and palette tokens for the monogram and its fill. A stack takes the ring colour of the surface it sits on.

- `--avatar-size` (`Ref<Control | Space | Measure>`, default `var(--control-md)`): Width and height.
- `--avatar-bg` (`Paint`, default `color-mix(in oklab, var(--_avatar-tone) var(--avatar-tint), var(--bg-card))`): The monogram's fill: the tone over the card, opaque, so it reads the same on any surface.
- `--avatar-fg` (`Paint`, default `color-mix(in oklab, var(--_avatar-tone) 72%, var(--ink))`): The monogram's ink: the tone pulled toward the theme's ink (4.5:1 or more on its fill).
- `--agent-edge` (`Paint`)
- `--avatar-stack-ring` (`Paint`, default `var(--card-bg, var(--bg-app))`): The ring around each avatar: the surface the stack sits on.

## Accessibility

`Avatar` is one `img` named by `name`; the image, the monogram or the character inside it is decorative, so a screen reader hears the name once whichever is showing. An agent with a `person` is named with them, alone or not, then `stateLabel` when given: "Scout, for maya, working". Someone outside is named by the name their server gave, the address, then "outside Arcadia". Every tone's ink clears 4.5:1 on its own fill in both themes.

Online or busy, the name reads ", online" or ", busy" after it ("Ada Lovelace, busy"), so presence is never told by the mark alone, and `removed` adds ", removed". Pass `stateLabel` wherever no words beside the avatar say the state: a picture's waiting, done and error rings look the same, and no state is told by colour alone. Under forced colours the mark and a ring take the system's text colour, busy's bar still cut through it, and a character's body keeps its colours, which are who it is.

Where the name is already written beside the avatar, as in the rows above, a reader hears it twice; in a dense list, give the avatar `aria-hidden`. Where presence shows, keep the avatar named: online and busy have no words of their own on screen.

The picker is two radio groups, Character and Color: one tab stop each, the arrow keys move (up and down by a row among the fifteen), each choice named ("Heart", "Blue") and the picked one checked; each character target is 40px and each colour 24px. In the colour row, a pointer's pick carries the ink ring to the new swatch; it lands whole from the keyboard.

Under reduced motion every character holds its state's resting pose and a working ring stands still. A character out of view, in a hidden tab or in a window left alone for a minute is not stepped.

## API reference

### Avatar

- `kind` (`"person" | "agent" | "outside"`, default `"person"`): Who the picture stands for: `person`, a circle; `agent`, its frame; `outside`, the mail glyph.
- `motionSrc` (`string`): The picture's animated rendition.
- `size` (`AvatarSize`): 16 / 20 / 24 / 28 / 32 / 36 / 40; 48 / 56 / 64 / 72 / 96; `text`, the surrounding line height.
- `presence` (`"online" | "busy" | "offline"`): A person's presence, on the picture's corner from 20 up, never at `text`: `online` the dot, `busy` the dot with its bar, `offline` nothing. An agent is only `online`, heard in its name and never drawn (S39).
- `removed` (`boolean`): Someone removed: the picture stays as it was, without presence, and the name reads ", removed" after it.
- `alone` (`boolean`): An agent's own picture without its `person`'s beside it, where the words beside it name the person.
- `rootStyle` (`RootStyle<AvatarKnobs>`): Typed StyleX override: layout and the `--avatar-*` knobs.
- `playMotion` (`"visible" | "intent"`): `visible`: a profile head or an open card, playing while it shows. `intent`: from 32, playing while the pointer or the focus is on it.
- `hue` (`"auto" | "neutral" | "blue" | "cyan" | "green" | "purple" | "pink"`, default `"auto"`): The monogram's hue. Hashed from the name.
- `badge` (`ReactNode`): A 14px mark on the bottom end corner (a `StatusDot`, a `ProviderMark`), its centre on the corner's arc at every size and the picture cut round it, in place of the presence dot. Its words belong in `aria-label`. Not at `text` or on an agent's character.
- `name` (`string`): The name: what a reader hears, and the source of the initials and their hue.
- `picture` (`string`): The picture's address; without one, or while it loads or when it fails, the initials of the name.
- `avatar` (`AgentAvatarValue`): The stored avatar: a character, or a photo with its character as the stand-in. A photo renders when `photoSrc` is given, whatever its `sha`; a malformed or legacy record falls back safely through `parseAvatar`. Without it, the agent's monogram, or `photoSrc`, in its frame.
- `photoSrc` (`string`): The still photo. For an animated photo, pass its standalone poster here, never the moving file.
- `placeholderSrc` (`string`)
- `state` (`AgentAvatarState | LegacyAgentAvatarState`, default `idle`): What the agent is doing: `idle`, `working`, `waiting`, `sleeping`, `done`, `error`. A character shows it in its face and body (while working the whole body turns once round now and then); a photo in its ring. The older names still read (`thinking`, `composing`: working; `failed`: error; `asleep`: sleeping).
- `stateLabel` (`string`): The state in the product's words ("working", "waits for your answer"): heard after the name, "Scout, working". Pass it wherever the words beside the picture do not say the state: a photo's waiting, done and error rings look alike.
- `activityAt` (`number`): Last activity in Unix milliseconds. Defaults to when this avatar started showing the working state.
- `still` (`boolean`): Hold the state's resting pose, with no life (a picker's cells). Reduced motion always holds it.
- `paused` (`boolean`): Holds the resting pose and the photo's ring still until lifted.
- `ready` (`boolean`): Shows the ready pose while the agent is idle, for the agent whose chat is open.
- `poke` (`boolean`): A press hops the character, then it smiles. Only where a press means nothing else.
- `enter` (`boolean`): Pops in when its working character starts moving. Never under reduced motion or on a hydrated page.
- `person` (`{ name: string; picture?: string }`): The person it acts for: heard after the name ("Scout, for maya"), and their picture a step smaller beside it unless `alone`.
- `address` (`string`): The address it came from, whole, as their server gave it.

Rest props go to `HTMLAttributes<HTMLSpanElement>`.

### AvatarStack

- `items` (`AvatarStackItem[]`, required): The people and agents, in order; the first sits on top.
- `size` (`16 | 20 | 24`, default `16`): Each avatar's size.
- `max` (`number`, default `3`): At most this many avatars; the rest fold into a `+n` count.
- `label` (`string`): Accessible name for the whole stack ("People and agents on act"); the names follow it.
- `rootStyle` (`RootStyle<AvatarStackKnobs>`): Typed StyleX override: layout and the ring knob.

Rest props go to `HTMLAttributes<HTMLSpanElement>`.

### AgentAvatarPicker

- `value` (`CharacterAvatar`, required): The character as it is now.
- `onChange` (`(next: CharacterAvatar) => void`, required): A character or a colour was picked: the whole next record, with only `shape` or `hue` changed (write it at once; the picker holds no state). Every other stored field (`color`, `face`, `seed`, `tilt`) is kept as it was.
- `onShuffle` (`() => void`): Shuffle: a new random character. Omit to hide the button.
- `onReset` (`() => void`): Reset: back to the character the agent was created with. Omit to hide the button.
- `onUpload` (`(file: File) => void`): A picture was chosen (PNG, JPEG, WebP or GIF): the product crops and stores it.
- `hasPhoto` (`boolean`): The agent shows a photo now: offers Remove photo (with `onRemovePhoto`).
- `onRemovePhoto` (`() => void`): Remove the photo: the character shows again.
- `name` (`string`, required): The agent's name, for the controls' accessible names.
- `rootStyle` (`RootStyle`): Typed StyleX override: where the picker sits.

Rest props go to `HTMLAttributes<HTMLDivElement>`.
