AgentAvatar
The avatar you actually drop into a list.
What it chooses between
In order:
- A picture, if
pictureUrlis set - A group cluster, if
membersis non-empty - A character, derived from
id
Which means an application can pass whatever it has and get something sensible, rather than branching at every call site.
Identity without storage
Shape and ink are hashed from id when not given explicitly, so every user has a consistent character and you store nothing. Two clients, two sessions and a server render all agree.
Pass shape or color on the agent to override either independently.
Face style
Put face: 'line' on the agent for the line face. The nose is hashed from id like the shape and ink, so it is as stable as they are; set nose to choose one or null for none.
A cast preset can carry a face and nose too; an explicit value on the agent wins over the preset, and the preset over the hash.
Sizes
Still and halo
still renders an image instead of an animation — the right choice in long lists. halo adds a soft colour wash derived from the character's own hue.
Fill
fillPx sets the size of the character inside the circle. The circle keeps its size; only what is drawn inside it changes, so smaller than the circle leaves a margin and larger crops it. The default fills the circle exactly. It is a custom property rather than a width on the child, because the child is an img in two of the three branches and the stylesheet already sizes those.
While the shape is changing
isMorphingShape says the shape is being changed under the character right now — the editor is open and someone is clicking through the grid. While it is true the avatar holds its last settled state for the settle window (SETTLE_MS, through useMarkSettle), so a morph is one change rather than two. A body that changes shape and expression in the same frame does not read as the same character with a new outline; it reads as a different character appearing.
Accessibility
The avatar is aria-hidden unless it has a picture with a name. When an avatar stands alone with no adjacent text, give it a name yourself — see accessibility.
API
| Prop | Type | Default | Description |
|---|---|---|---|
agent* | AgentLike | — | — |
className | string | — | — |
emotionId | string | — | Protocol id, for hosts that speak the wire format. Ignored when `state` is given. |
face | "cute" | "eyes" | "line" | — | Face style, overriding whatever the agent identity resolves to. |
fillPx | number | — | Size of the character inside the circle. Smaller than the circle leaves a margin; larger crops it. Defaults to filling the circle exactly. |
halo | boolean | false | Soft colour wash behind the character. |
isMorphingShape | boolean | false | The shape is being changed under the character right now. Holds the last settled state for the settle window, so a morph is one change rather than two. A body that changes shape and expression in the same frame does not read as the same character having a new outline; it reads as a different character appearing. |
lineWeight | number | — | Stroke width multiplier. Not part of an identity, so always explicit. |
nose | "slant" | "angular" | "hook" | "long" | "curve" | "bow" | null | — | Nose, overriding the identity. `null` draws no nose. |
size | "xs" | "sm" | "md" | "lg" | "xl" | 'md' | — |
sizePx | number | — | Exact pixel size, overriding `size`. |
state | "idle" | "sleeping" | "drowsy" | "bored" | "waking" | "powering-down" | "listening" | "thinking" | "searching" | "reading" | "writing" | "working" | "loading" | "progress" | "radar" | "orbit" | "dictating" | "uploading" | "sending" | "receiving" | "messaging" | "waiting" | "spawning" | "composing" | "dragging" | "happy" | "excited" | "laughing" | "playful" | "proud" | "celebrate" | "bouncing" | "shy" | "sad" | "angry" | "confused" | "suspicious" | "surprised" | "scared" | "curious" | "humming" | "alerting" | "notifying" | "refusing" | — | — |
still | boolean | false | Render a still image instead of an animation. |
style | CSSProperties | — | — |
Next
- AvatarStack — overlapping group avatars
- Badges and status — unread counts and status dots
- Agent roster — twenty faces down the side