Avatar
Display one person or agent avatar, a compact overlapping avatar group with rolling +N overflow, or an interactive realtime presence stack.
import { Avatar } from '@uthereal/ui/avatar'Avatar playground
Overview
Avatar unifies three identity patterns under one component contract: a single person or agent marker, a compact overlapping team group, and an interactive realtime presence stack. Pass name (and optional src) for a single face, or pass people to render a stack that reflows on join and leave and collapses overflow past max into a rolling +N counter. Set presence on a stack to add hover fan-out, a gliding spring-width name pill, arrow-key navigation, typing indicators, and a click-to-list roster popover.
Use Avatar to identify people, accounts, assistants, or active collaborators. Use Avatar input to upload or crop a profile photo, and Hover card for rich profile previews with bios and stats.
| Mode | Trigger props | Behavior | Best for |
|---|---|---|---|
| Single | name (+ optional src) | One face with lazy blur-in photo, two-letter initials or bot fallback, and optional corner presence mark. | Profile headers, message rows, bylines. |
| Group | people (presence off) | Compact overlapping stack (6px overlap) with join/leave reflow, hover name tips, and rolling +N chip. | Assignees, project owners, static teams. |
| Presence | people + presence:true | Reserved header width, hover fan-out, gliding name pill, arrow keys, typing dots, and roster popover list. | Realtime docs, boards, calls, canvases. |
Usage
'use client'
import { Avatar, type AvatarPerson } from '@uthereal/ui/avatar'
export function DocumentHeader({
title,
selfId,
people,
onFollow,
}: {
title: string
selfId: string
people: readonly AvatarPerson[]
onFollow: (person: AvatarPerson) => void
}) {
return (
<header>
<h1>{title}</h1>
<Avatar
people={people}
presence
selfId={selfId}
align="end"
max={4}
label="People here now"
heading="Here now"
onPersonSelect={onFollow}
/>
</header>
)
}Pass decorative when rendering a single avatar beside a visible name (such as a table cell or byline) so screen readers do not announce the name twice.
Examples
Use <SchemaPlayground /> above to inspect individual props, recipe, theme, and motion presets. The example sets below cover single faces, compact groups, and realtime presence stacks.
Single avatars
Compare xs–xl diameters, square corners for teams or bots, kind="agent" bot fallbacks, initials fallback when src is omitted, and corner presence marks.
Avatar groups
Pass people with presence={false} (the default) for a compact overlapping team stack. Members beyond max collapse into a rolling +N counter, and hovering any face shows its name above the stack without shifting layout.
Presence stacks
Add presence for realtime rooms. The stack reserves its full max + 1 width so adjacent header controls stay fixed as people join or leave, fans out gently under a fine pointer with a gliding name pill, displays active, idle, and typing indicators, and opens a full roster popover on click.
Presence statuses & sizing
Both single avatars and stack members share one presence status vocabulary.
status | Visual mark | Portrait treatment | Default spoken label (statusLabels) |
|---|---|---|---|
online | Green dot (--ui-success) with surface cutout ring | Normal | Online |
active | Green dot (--ui-success) with surface cutout ring | Normal | Active now |
offline | Muted grey dot (--ui-muted) | Normal | Offline |
idle | Muted dot (--ui-border-strong) | 50% surface veil | Idle |
typing | High-contrast pill (--ui-text) with 3 bouncing dots | Normal | Typing |
size | Single diameter | Stack diameter | Stack step (68%) | Initials text | Fallback icon | Status dot |
|---|---|---|---|---|---|---|
xs | 20 px | Clamps to sm | — | 9 px | 12 px | 6 px |
sm | 28 px | 28 px | 19 px | 10 px | 14 px | 8 px |
md | 36 px | 36 px | 24 px | 12 px | 16 px | 10 px |
lg | 48 px | 44 px | 30 px | 14 px | 20 px | 12 px |
xl | 88 px | Clamps to lg | — | 22 px | 36 px | 14 px |
API reference
Serializable arguments and defaults come directly from avatarConfigSchema. Pass either name (single mode) or people (stack mode); never both.
| Argument | Type / default | Description |
|---|---|---|
name | string— | Single mode: accessible name and source of two-letter initials ("Sam Rivera" shows SR). Omit and pass people for a stack. |
src | string— | Single mode: picture URL (http(s) or relative), loaded lazily. Loading photos fade in from a soft blur; cached photos show immediately; initials or the bot icon appear if loading fails. |
status | online | offline | active | idle | typing— | Single mode: presence shown as the corner mark: online or active (green dot), offline (grey dot), idle (dimmed portrait with muted dot), or typing (three-dot pill). |
detail | string— | Single mode: optional activity text. |
people | AvatarPerson[]— | Stack mode: people in display order, up to 50 with unique ids. Add, remove, reorder, or update status to animate reflow in place. |
max | integerDefault: 4 | Visible faces before remaining members collapse into the rolling +N overflow chip (1–12). |
align | start | endDefault: "start" | Side the stack anchors to within its reserved width (start or end). Use end in right-aligned headers next to action buttons. |
selfId | string— | Id of the current user in people; appends " (you)" in the gliding label and roster popover. |
label | stringDefault: "People" | Accessible name of the stack group or presence trigger (count is appended in presence mode). |
heading | string— | Heading of the presence roster popover. Defaults to label when omitted. |
emptyLabel | stringDefault: "No one else is here right now" | Fallback message shown inside the presence roster when people is empty. |
presence | booleanDefault: false | Enables interactive presence stack mode: reserved header width, hover fan-out, gliding name label, ArrowLeft/ArrowRight navigation, typing pills, and click-to-list roster popover. |
defaultOpen | booleanDefault: false | Initial open state of the presence roster popover. Later edits do not reset a mounted instance. |
announce | booleanDefault: true | Announces joins and leaves in a polite live region, such as "Emma Collins joined". |
action | string— | Host-registered action fired on overflow click (group mode) or roster row selection (presence mode, with the picked person id). |
kind | user | agentDefault: "user" | user falls back to initials; agent falls back to a bot icon for assistants and automations. |
shape | circle | squareDefault: "circle" | circle for people; square uses the theme radius for teams or agents. |
size | xs | sm | md | lg | xlDefault: "md" | Diameter: 20 (xs), 28 (sm), 36 (md), 48 (lg), or 88 (xl) px. Stacks clamp to sm (28), md (36), and lg (44) px. |
statusLabel | string— | Custom announced status text, e.g. "In a meeting". Omit to use statusLabels. |
statusLabels | AvatarStatusLabelsDefault: {"online":"Online","offline":"Offline","active":"Active now","idle":"Idle","typing":"Typing"} | Announced text for online, offline, active, idle, and typing. Override to localize. |
overflowLabel | stringDefault: "{count} more" | Accessible label template for the +N chip; {count} is replaced with the hidden count. |
recipe | studio | softDefault: "studio" | Visual treatment; behavior remains identical across recipes. |
motion | none | subtle | expressiveDefault: "subtle" | subtle animates photo blur-in, status pops, join/leave reflow, +N rolling, and the gliding name pill; none disables animation immediately. Reduced motion uses a 120ms crossfade. |
motionOptions | AvatarMotionOptionsDefault: {} | Motion options for label swaps and the presence roster popover; durations are milliseconds. |
theme | AvatarTheme— | Color mode, accent, and tokens for surface, ink, status colors, radii, elevation, and avatar size scale. |
dir | ltr | rtl— | Reading direction; stacks, overlap, arrow keys, and status marks mirror in RTL. Omit to inherit page direction. |
decorative | booleanDefault: false | Hides single avatar from assistive technology when a visible name sits beside it. |
React integration
| Prop | Purpose |
|---|---|
open, onOpenChange | Controlled open state and change callback for the presence roster popover (onOpenChange fires in both modes). |
onPersonSelect(person) | Turns each presence roster row into a button; closes the popover after selection. |
onAction(action, personId?) | Fires action on group overflow click (no id) or presence roster row pick (with the picked person.id). |
renderIcon(name, { size, slot }) | Replaces the decorative fallback bot or user glyph (slot is 'fallback'). |
renderImage(props) | Renders photos with a custom framework image component (such as next/image); spread all received props. |
portalContainer | Custom portal mount target for the presence roster popover; defaults to the enclosing layer, provider, or body. |
preset | Application defaults overridden by explicit instance props (name, src, status, detail, people excluded). |
tokens | --ui-* CSS variables applied after the typed theme on both the root and the portalled roster popover. |
ref, className, style, rest | Forwarded to the root <span> element. |
Keyboard & accessibility
| Key | Mode | Action |
|---|---|---|
Tab | Presence | Focuses the presence stack trigger (or the overflow action button in group mode when action). |
ArrowLeft / ArrowRight | Presence | Moves the name pill across visible faces and the +N chip while focused (mirrored in RTL). |
Enter / Space | Presence | Opens the anchored roster popover and moves focus into it. |
Tab (inside roster) | Presence | Moves between interactive member rows when onPersonSelect or action + onAction is set. |
Escape | Presence | Closes the roster popover and restores focus to the stack trigger. |
- Single mode renders
role="img"named"<name>"or"<name>, <status>", oraria-hidden="true"whendecorativeis enabled. - Group mode renders
role="group"named bylabel; the+Nchip carriesrole="img"(or<button>whenactionis set) named viaoverflowLabel. - Presence mode renders one trigger button named
"<label>, <N> person|people"witharia-haspopupandaria-expandedfrom the internal popover surface. Individual faces, status marks, and the gliding pill are decorative because the roster repeats every member's name, status, and detail in text. - Live announcements: when
announceistrue(default), a pre-mountedrole="status" aria-live="polite"region announces joins and leaves (such as"Emma Collins joined. Kai Chen left"). Status changes are not announced to avoid chatter. - RTL & high contrast: layout uses CSS logical properties, stack direction, overlap, arrow keys, and popover alignment mirror automatically under
dir="rtl"(or inherited page direction). Underforced-colors: active, borders useCanvasText, dots useCanvasText/GrayText, labels invert toCanvasTextonCanvas, and keyboard focus draws aHighlightoutline.
Motion & theming
| Mode | Photo & status mark | Stack join / leave & +N | Hover fan-out & name pill | Typing dots |
|---|---|---|---|---|
motion="subtle" (default) | 240 ms blur-in photo; snappy spring dot pop | Morph pop (0.4 → 1), smooth slide, roll +N | 4 px fan + 2 px lift; morph width & glide pill | 1.1 s rise loop |
motion="expressive" | 240 ms blur-in photo; snappy spring dot pop | Morph pop, smooth slide, roll +N | 6 px pill offset; morph width & glide pill | 1.1 s rise loop |
prefers-reduced-motion: reduce | Immediate photo; 120 ms opacity mark swap | 120 ms opacity fade; no pop, slide, or roll | No fan or rise; instant width/position, 120 ms | Static (80% ink) |
motion="none" | Immediate (0 ms) | Immediate (0 ms) | Disabled (0 ms) | Static (80% ink) |
Cached photos display immediately without blurring; only photos still downloading after mount fade in from a 4 px blur. Tune name pill swaps and popover timing with motionOptions (labelDuration, labelOffset, duration, exitDuration, offset, scale).
| Token group | CSS custom properties |
|---|---|
| Surfaces & edges | --ui-surface, --ui-surface-raised, --ui-highlight, --ui-border, --ui-border-strong, --ui-border-width, --ui-focus-ring |
| Ink & status | --ui-text, --ui-text-secondary, --ui-muted, --ui-success, --ui-warning, --ui-danger |
| Shape, type & elevation | --ui-radius, --ui-radius-sm, --ui-popup-radius, --ui-shadow, --ui-shadow-raised, --ui-font, --ui-font-size, --ui-font-weight |
| Avatar scale | --ui-avatar-size, --ui-avatar-text-size, --ui-avatar-icon-size, --ui-avatar-status-size |
Set --ui-avatar-ring via tokens or style when placing a stack over a tinted surface so the face and dot cutouts match the background. UtherealProvider supplies application-wide recipe, theme, and motion defaults below preset and instance props.
Composition
In agent compositions, Avatar is a leaf component. Register action on the host when set; roster open state is transient UI state (onOpenChange).
{
"type": "Avatar",
"props": {
"presence": true,
"align": "end",
"max": 4,
"selfId": "maya",
"label": "People here now",
"heading": "Here now",
"people": [
{
"id": "maya",
"name": "Maya Lin",
"status": "active",
"detail": "Editing Intro"
},
{
"id": "liam",
"name": "Liam Patel",
"status": "typing",
"detail": "Commenting on Pricing"
},
{ "id": "noah", "name": "Noah Brooks", "status": "idle" }
]
},
"children": []
}