UI

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

Loading interactive preview…

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.

ModeTrigger propsBehaviorBest for
Singlename (+ 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.
Grouppeople (presence off)Compact overlapping stack (6px overlap) with join/leave reflow, hover name tips, and rolling +N chip.Assignees, project owners, static teams.
Presencepeople + presence:trueReserved 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.

statusVisual markPortrait treatmentDefault spoken label (statusLabels)
onlineGreen dot (--ui-success) with surface cutout ringNormalOnline
activeGreen dot (--ui-success) with surface cutout ringNormalActive now
offlineMuted grey dot (--ui-muted)NormalOffline
idleMuted dot (--ui-border-strong)50% surface veilIdle
typingHigh-contrast pill (--ui-text) with 3 bouncing dotsNormalTyping
sizeSingle diameterStack diameterStack step (68%)Initials textFallback iconStatus dot
xs20 pxClamps to sm—9 px12 px6 px
sm28 px28 px19 px10 px14 px8 px
md36 px36 px24 px12 px16 px10 px
lg48 px44 px30 px14 px20 px12 px
xl88 pxClamps to lg—22 px36 px14 px

API reference

Serializable arguments and defaults come directly from avatarConfigSchema. Pass either name (single mode) or people (stack mode); never both.

ArgumentType / defaultDescription
namestring—Single mode: accessible name and source of two-letter initials ("Sam Rivera" shows SR). Omit and pass people for a stack.
srcstring—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.
statusonline | 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).
detailstring—Single mode: optional activity text.
peopleAvatarPerson[]—Stack mode: people in display order, up to 50 with unique ids. Add, remove, reorder, or update status to animate reflow in place.
maxintegerDefault: 4Visible faces before remaining members collapse into the rolling +N overflow chip (1–12).
alignstart | endDefault: "start"Side the stack anchors to within its reserved width (start or end). Use end in right-aligned headers next to action buttons.
selfIdstring—Id of the current user in people; appends " (you)" in the gliding label and roster popover.
labelstringDefault: "People"Accessible name of the stack group or presence trigger (count is appended in presence mode).
headingstring—Heading of the presence roster popover. Defaults to label when omitted.
emptyLabelstringDefault: "No one else is here right now"Fallback message shown inside the presence roster when people is empty.
presencebooleanDefault: falseEnables interactive presence stack mode: reserved header width, hover fan-out, gliding name label, ArrowLeft/ArrowRight navigation, typing pills, and click-to-list roster popover.
defaultOpenbooleanDefault: falseInitial open state of the presence roster popover. Later edits do not reset a mounted instance.
announcebooleanDefault: trueAnnounces joins and leaves in a polite live region, such as "Emma Collins joined".
actionstring—Host-registered action fired on overflow click (group mode) or roster row selection (presence mode, with the picked person id).
kinduser | agentDefault: "user"user falls back to initials; agent falls back to a bot icon for assistants and automations.
shapecircle | squareDefault: "circle"circle for people; square uses the theme radius for teams or agents.
sizexs | 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.
statusLabelstring—Custom announced status text, e.g. "In a meeting". Omit to use statusLabels.
statusLabelsAvatarStatusLabelsDefault: {"online":"Online","offline":"Offline","active":"Active now","idle":"Idle","typing":"Typing"}Announced text for online, offline, active, idle, and typing. Override to localize.
overflowLabelstringDefault: "{count} more"Accessible label template for the +N chip; {count} is replaced with the hidden count.
recipestudio | softDefault: "studio"Visual treatment; behavior remains identical across recipes.
motionnone | 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.
motionOptionsAvatarMotionOptionsDefault: {}Motion options for label swaps and the presence roster popover; durations are milliseconds.
themeAvatarTheme—Color mode, accent, and tokens for surface, ink, status colors, radii, elevation, and avatar size scale.
dirltr | rtl—Reading direction; stacks, overlap, arrow keys, and status marks mirror in RTL. Omit to inherit page direction.
decorativebooleanDefault: falseHides single avatar from assistive technology when a visible name sits beside it.

React integration

PropPurpose
open, onOpenChangeControlled 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.
portalContainerCustom portal mount target for the presence roster popover; defaults to the enclosing layer, provider, or body.
presetApplication 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, restForwarded to the root <span> element.

Keyboard & accessibility

KeyModeAction
TabPresenceFocuses the presence stack trigger (or the overflow action button in group mode when action).
ArrowLeft / ArrowRightPresenceMoves the name pill across visible faces and the +N chip while focused (mirrored in RTL).
Enter / SpacePresenceOpens the anchored roster popover and moves focus into it.
Tab (inside roster)PresenceMoves between interactive member rows when onPersonSelect or action + onAction is set.
EscapePresenceCloses the roster popover and restores focus to the stack trigger.
  • Single mode renders role="img" named "<name>" or "<name>, <status>", or aria-hidden="true" when decorative is enabled.
  • Group mode renders role="group" named by label; the +N chip carries role="img" (or <button> when action is set) named via overflowLabel.
  • Presence mode renders one trigger button named "<label>, <N> person|people" with aria-haspopup and aria-expanded from 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 announce is true (default), a pre-mounted role="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). Under forced-colors: active, borders use CanvasText, dots use CanvasText / GrayText, labels invert to CanvasText on Canvas, and keyboard focus draws a Highlight outline.

Motion & theming

ModePhoto & status markStack join / leave & +NHover fan-out & name pillTyping dots
motion="subtle" (default)240 ms blur-in photo; snappy spring dot popMorph pop (0.4 → 1), smooth slide, roll +N4 px fan + 2 px lift; morph width & glide pill1.1 s rise loop
motion="expressive"240 ms blur-in photo; snappy spring dot popMorph pop, smooth slide, roll +N6 px pill offset; morph width & glide pill1.1 s rise loop
prefers-reduced-motion: reduceImmediate photo; 120 ms opacity mark swap120 ms opacity fade; no pop, slide, or rollNo fan or rise; instant width/position, 120 msStatic (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 groupCSS 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": []
}

On this page