Examples

Sizes and fallbacks

Initials use a stable colour per name.

Preview
Example.tsx
import { Avatar, HStack } from '@reactloom/ui';

export default function Example() {
  return (
    <HStack gap="3">
      <Avatar size="xs" name="Ada Lovelace" />
      <Avatar size="sm" name="Grace Hopper" />
      <Avatar name="Alan Turing" />
      <Avatar size="lg" name="Katherine Johnson" />
      <Avatar size="xl" name="Margaret Hamilton" shape="square" />
      <Avatar size="lg" aria-label="Unknown user" />
    </HStack>
  );
}

Group

Extra avatars collapse into an accessible “+N” counter.

Preview
Example.tsx
import { Avatar, AvatarGroup } from '@reactloom/ui';

const members = ['Ada Lovelace', 'Grace Hopper', 'Alan Turing', 'Katherine Johnson', 'Margaret Hamilton', 'Edsger Dijkstra'];

export default function Example() {
  return (
    <AvatarGroup aria-label="Project members" max={4}>
      {members.map((name) => (
        <Avatar key={name} name={name} />
      ))}
    </AvatarGroup>
  );
}

API reference

Avatar props

Avatar props
PropTypeDefault
src
Falls back to initials when missing or broken.
string—
name
Accessible name and initials.
string—
alt
"" when the name is shown next to it.
string—
size
'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
shape
'circle' | 'square''circle'

AvatarGroup props

AvatarGroup props
PropTypeDefault
max
number—
size
Applied to all.
AvatarSize'md'
moreLabel
(n: number) => string“{n} more”
aria-label
Name the group.
string—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

Avatar

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-shape]circle · square
[data-size]xs · sm · md · lg · xl
[data-tone]present when on

Theme tokens it reads

--pl-color-accent-fg --pl-color-accent-subtle --pl-color-bg-muted --pl-color-danger-fg --pl-color-danger-subtle --pl-color-fg-default --pl-color-fg-muted --pl-color-success-fg --pl-color-success-subtle --pl-color-warning-fg --pl-color-warning-subtle --pl-radius-md

AvatarGroup

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-size]xs · sm · md · lg · xl

Theme tokens it reads

--pl-color-accent-fg --pl-color-accent-subtle --pl-color-bg-muted --pl-color-bg-subtle --pl-color-bg-surface --pl-color-danger-fg --pl-color-danger-subtle --pl-color-fg-default --pl-color-fg-muted --pl-color-success-fg --pl-color-success-subtle --pl-color-warning-fg --pl-color-warning-subtle --pl-radius-md

Accessibility

  • Images use the name as alt text; fallbacks expose role="img" with the same name.
  • Use alt="" when the name is already visible beside the avatar.

Usage guidelines

Do

  • Show names next to avatars in lists.

Don’t

  • Don’t rely on avatars alone to identify people.