Skip to content

Avatar

Avatar

<Avatar src="/u/alice.jpg" alt="Alice Liddell" fallback="AL" />
<Avatar fallback="?" size="lg" />
<Avatar shape="square" fallback="ML" />

Install: @helixui/core

import { Avatar } from '@helixui/core'

status: stable · since: 0.1.0

Tags: user, identity, image, fallback, circle

Live playground

Open the full editor or source on GitHub.

Anatomy

● ← circular image; if missing → initials on tinted bg

Layout

  • displayinline-block
  • widthcontent
  • heightcontent
  • intrinsicSize24/32/40/48/64px square (xs/sm/md/lg/xl)
  • stackabletrue
  • fullBleedfalse

Visual

A circular image with rounded fallback when the image fails to load. Fallback shows uppercase initials on a deterministic tinted background derived from the name. Optional ring (border) or PresenceDot can sit on top.

Props

NameTypeDefaultDescription
srcstringImage URL.
altstringAccessible label. Used as aria-label. If empty, fallback is used.
fallbackstringText to display when no image is available — typically initials.
size'xs' | 'sm' | 'md' | 'lg' | 'xl'mdAvatar size.
shape'circle' | 'square'circleAvatar shape.

Tokens used

color.bg.action.neutral.default, color.text.secondary, font.family.sans, font.weight.semibold, font.size.xs, font.size.sm, font.size.md, font.size.xl, radius.full, radius.md

Accessibility

Notes

  • Always pass alt when the avatar identifies a real person or entity. Use empty alt="" only when the avatar is purely decorative and accompanied by visible text.
  • Initials in fallback should be 1–2 characters.

Composes with

ComponentRelationNote
AvatarGroupchildUsed inside AvatarGroup for stacked rows.
PresenceDotsiblingRender PresenceDot anchored to the avatar.
ChatMessagechildCommon as the leading slot of a ChatMessage.

Prompt examples

These are the AI prompt → JSX mappings used by the helixui prompt DSL and integrations like Cursor / Claude Code.

user avatar with initials fallback

“avatar for “Sara Tang""

<Avatar src={user.imageUrl} fallback="ST" alt="Sara Tang" />

large avatar in a profile header

“64px avatar in a profile card”

<Avatar size="xl" src={user.imageUrl} fallback="ST" />