Avatar

A black-bordered avatar frame with 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 needsStatus variants or pulse — Status only owns its color and behavior.

Group#

+3

Sizes#

xlprofile/detail · 64px
lglarge identity · 48px
mdpanel header · 36px
smlist rows · 32px
xscompact rows · 20px
2xsnav / DM rows · 18px
3xsinline preview · 14px

API#WIP

PropTypeDefaultDescription
size"xl" | "lg" | "md" | "sm" | "xs" | "2xs" | "3xs"Fixes the frame size and border width (xl 64px down to 3xs 14px).
type"agent" | "human"Role-keyed bg: agent → cyan, human → lavender (+ text-black for the placeholder).
childrenReactNodeComposed parts: AvatarImage, AvatarFallback, AvatarBadge. Defaults to a placeholder AvatarFallback when empty.
...propsBase UI Avatar.Root.PropsNative span attributes (className for positioning, etc.).
PropTypeDefaultDescription
...propsBase UI Avatar.Image.PropsManaged image part. Fills the frame and reveals fallback while loading or on error.
PropTypeDefaultDescription
...propsBase UI Avatar.Fallback.PropsFallback part. Defaults to the scaled User icon when no children are passed.
PropTypeDefaultDescription
renderuseRender render propOptional element override. Default is the solid dot; pass render={<Status … />} for activity/presence chrome.
...propsuseRender.ComponentProps<"span">Corner shell on the avatar. The default dot and custom renders auto-scale from the parent size.
PropTypeDefaultDescription
...propsComponentProps<"div">Overlapping avatar stack.
PropTypeDefaultDescription
...propsComponentProps<"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, theme, 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, badge, and border scale from the parent size.
Theme surfaceBrutal square frame with role background and black border.Theme-aware frame: brutal keeps square border; elegant uses the avatar family surface.
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 / 64pxThis is a stable profile/detail scale, not a one-off layout adjustment.Use <Avatar size="xl">; image/fallback fills the 64px 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 / 48pxMention 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 / 36pxPanel 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 / 32pxThis 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 / 18pxSidebar and DM rows need exact source density, so this stays a public compact step on the t-shirt scale.Use <Avatar size="2xs"> inside SidebarItemIcon.
compact-list20px frame, 1px borderagent 18 / human 18 / icon 12xs / 20pxThis 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.