Avatar

A square sticker frame with an ink edge, a role-keyed background, managed image, and placeholder.

Preview#

Controls
import { Avatar, AvatarBadge, AvatarFallback, AvatarImage } from "raft-ui";

<Avatar size="md" type="human">
  <AvatarImage src="/avatar.png" alt="" />
  <AvatarFallback />
  <AvatarBadge />
</Avatar>

Avatar image#

Source AvatarSlot parsed pixel:*, uploaded human avatars, and Gravatar inside the component. Current Avatar keeps that app-domain resolution outside: callers pass a resolved image to AvatarImage, or leave AvatarFallback visible for placeholders and load failures.

Agent pixel
Agent image
Human image
Human placeholder

Badge#

The default dot and custom indicator both auto-scale with the avatar's size. Pass render={<Status />} when the indicator needs Status variants — Status only owns its color.

presence sets the default dot's status light: online (the default), busy for an agent at work, error, offline, or external. The light never animates; label it when no word sits beside it.

WBMMCR

Badge offset#

offset places the badge anywhere on the avatar. It is the position of the badge's centre, measured from the avatar's top-left corner, as [x, y]. Numbers are px; strings are any CSS length, and percentages are of the avatar's size — so the four corners are [0, 0], ["100%", 0], [0, "100%"] and ["100%", "100%"] at every size. Without offset the badge keeps the default bottom-right spot; size and stacking stay owned by the avatar either way.

Group#

+3

Sizes#

xlprofile/detail · 99px
lglarge identity · 51px
mdpanel header · 35px
smlist rows · 27px
xscompact rows · 19px
2xsnav / DM rows · 19px
3xsinline preview · 14px

API#WIP

size
"xl" | "lg" | "md" | "sm" | "xs" | "2xs" | "3xs"
Fixes the frame size on the DS 8n + 3 steps: xl 99, lg 51, md 35, sm 27, xs and 2xs 19, 3xs 14px. The ink edge stays 1.5px at every size.
type
"agent" | "human"
Role-keyed background: agent → stone until its sprite covers it, human → lavender.
children
ReactNode
Composed parts: AvatarImage, AvatarFallback, AvatarBadge. Defaults to a placeholder AvatarFallback when empty.
...props
Base UI Avatar.Root.Props
Native span attributes (className for positioning, etc.).
...props
Base UI Avatar.Image.Props
Managed image part. Fills the frame and reveals fallback while loading or on error.
...props
Base UI Avatar.Fallback.Props
Fallback part. Defaults to the scaled User icon when no children are passed.
presencedefault: "online"
"online" | "busy" | "error" | "offline" | "external"
The default dot's status light, from the same map as Status. Ignored when render draws its own indicator.
offset
[string | number, string | number]
Where the badge's centre sits, measured from the avatar's top-left: [x, y]. Numbers are px; strings are any CSS length, and percentages are of the avatar, so ["100%", 0] is the top-right corner at every size. Omit it to keep the default bottom-right spot.
render
useRender render prop
Optional element override. Default is the solid dot; pass render={<Status … />} for activity/presence chrome.
...props
useRender.ComponentProps<"span">
Corner shell on the avatar. The default dot and custom renders auto-scale from the parent size.
...props
ComponentProps<"div">
Overlapping avatar stack.
...props
ComponentProps<"span"> & { size: AvatarSize }
Trailing +N chip. Its size should match the sibling avatars.

Source AvatarSlot was a product-specific identity slot. Current Avatar is the reusable UI primitive: it keeps the frame, image, fallback, badge, and group behavior, while app-domain lookup stays outside. Dropped exact sizes are handled by parent compositions, not by leaking every source callsite density into the public avatar API.

AreaSourceCurrent
API surfaceAvatarSlot(context, type, agentAvatarUrl, humanAvatarUrl, gravatarHash, email)Avatar(size, type) plus AvatarImage, AvatarFallback, AvatarBadge children
Identity lookupAgentAvatar and GravatarAvatar are resolved inside AvatarSlot.Callers resolve URLs; Avatar only owns image/fallback rendering state.
Size modelTen callsite contexts, including 56px, 28px, 22px, and 18px one-offs.Seven public sizes: xl, lg, md, sm, xs, 2xs, 3xs.
Inner sizingEach context carries separate agent pixel, gravatar, and placeholder icon numbers.Fallback, icon, and badge scale from the parent size; the ink edge stays 1.5px.
Frame surfaceSquare frame with role background and black border.Sticker frame with an ink edge; agents sit on stone, people on lavender.
Extra partsNo badge or group primitive in AvatarSlot.Badge and group are first-class composition parts.
Source contextSource frameSource innerCurrent sizeReasonImplementation
profile-tile64px frame, 2px borderagent 60 / human 60 / icon 32xl / 99pxThis is a stable profile/detail scale, not a one-off layout adjustment.Use <Avatar size="xl">; image/fallback fills the 99px frame.
account-tile56px frame, 2px borderagent 52 / human 52 / icon 24No exact public stepOnly existed for account settings density, so keeping it would expose a layout-specific size as public API.Use lg inside compact account rows or xl for profile emphasis; let the row/card own surrounding spacing.
mention-card48px frame, 2px borderagent 44 / human 44 / icon 24lg / 51pxMention cards and identity popovers share this visual weight.Use <Avatar size="lg"> inside hover-card or identity header compositions.
panel-header36px frame, 2px borderagent 32 / human 32 / icon 18md / 35pxPanel headers need a distinct step between list rows and mention cards.Use <Avatar size="md"> in PanelHeader visual/icon slots.
surface-list32px frame, 2px borderagent 28 / human 28 / icon 16sm / 27pxThis is the common list-row avatar size across source callsites.Use <Avatar size="sm"> for list item leading media.
members-row28px frame, 1px borderagent 26 / human 24 / icon 14No exact public stepIt was a narrow density correction for member rows and sits too close to both sm and xs.Use sm when the row has normal text rhythm; use xs when the member avatar is secondary metadata.
creator-link22px frame, 1px borderagent 20 / human 20 / icon 12No exact public stepIt belongs to inline link composition, not the avatar primitive scale.Use xs and tune the link's gap/line-height in the parent composition instead of adding a 22px avatar size.
sidebar-list18px frame, 1px borderagent 16 / human 16 / icon 102xs / 19pxSidebar and DM rows keep their own public step on the t-shirt scale; it renders at the same 19px as xs.Use <Avatar size="2xs"> inside SidebarItemIcon.
compact-list20px frame, 1px borderagent 18 / human 18 / icon 12xs / 19pxThis is the reusable compact size for dense rows and metadata.Use <Avatar size="xs"> for compact rows and dense metadata.
preview-mini14px frame, 1px borderagent 14 / human 14 / icon 103xs / 14pxInline previews need a true miniature avatar rather than shrinking xs ad hoc.Use <Avatar size="3xs"> in quoted/preview chip compositions.