Skip to content

Avatar

import { Avatar } from '@delightstack/components';
View code
<Avatar src="/avatars/alice.jpg" name="Alice Johnson" />
<Avatar
src={user.avatar_url}
name={user.name}
size="3"
status="online"
/>

When no src is provided (or the image fails to load), the avatar displays initials derived from the name prop on a deterministic OKLCH-hashed background color.

View code
<Avatar name="John Doe" size="2" />
<Avatar name="Alice" size="2" />
<Avatar name="Jean-Pierre Martin" size="2" />

Six size presets are available, from inline mentions to hero sections.

View code
<Avatar name="A" size="0" /> <!-- 24px -->
<Avatar name="A" size="1" /> <!-- 32px (default) -->
<Avatar name="A" size="2" /> <!-- 40px -->
<Avatar name="A" size="3" /> <!-- 56px -->
<Avatar name="A" size="4" /> <!-- 80px -->
<Avatar name="A" size="5" /> <!-- 120px -->
View code
<Avatar name="Online User" status="online" />
<Avatar name="Away User" status="away" />
<Avatar name="Busy User" status="busy" />
<Avatar name="Offline User" status="offline" />
<!-- Status dot on top -->
<Avatar name="Top Status" status="online" status_position="top" />
View code
<!-- Dot indicator -->
<Avatar name="Dot Badge" badge />
<!-- Numeric badge -->
<Avatar name="Count Badge" badge={5} />
<!-- Numbers above 99 display as "99+" -->
<Avatar name="Many Notifications" badge={150} />
View code
<Avatar name="Square" square size="3" />
<Avatar name="Ringed" ring size="3" />
<Avatar name="Custom Ring" ring ring_color="red" size="3" />

When onclick is provided, the avatar becomes a focusable button with hover/active states.

<Avatar
src={user.avatar_url}
name={user.name}
onclick={() => openProfile(user)}
/>
View code
<Avatar
name="Alice Johnson"
tooltip="Alice Johnson - Online"
/>
View code
<Avatar skeleton name={loading ? undefined : 'Ada Lovelace'} size="3" />
PropTypeDefaultDescription
srcstring-Image URL
namestring-Name for initials fallback and auto alt text
size'0' | '1' | '2' | '3' | '4' | '5''1'Avatar size preset
squarebooleanfalseRounded square shape instead of circle
status'online' | 'away' | 'busy' | 'offline'-Status indicator dot
status_position'top' | 'bottom''bottom'Status dot position
badgenumber | boolean-Notification badge (true for dot, number for count)
ringbooleanfalseShow colored ring around avatar
ring_colorstring-Custom ring color
skeletonbooleanfalseShow a skeleton until the avatar has content — it dismisses itself once the image loads (or immediately when name/children can render)
tooltipstring''Tooltip text
onclick(e: MouseEvent) => void-Click handler (makes avatar interactive)
idstringautoElement ID
classstring''Additional CSS classes
childrenSnippet-Custom fallback content
EventDetailDescription
onclickMouseEventFires when an interactive avatar is clicked
  • name prop auto-generates alt text on the image element
  • Decorative avatars (no name) use alt=""
  • Status indicator has aria-label (e.g., “Online”)
  • Badge has aria-label (e.g., “5 notifications”)
  • Interactive avatars (with onclick) receive role="button", are focusable, and support Enter/Space activation
  • Focus ring is visible on keyboard navigation
  • Respects prefers-reduced-motion for pulse animation on online status