Data display
Avatar
A person’s or entity’s image with initials and icon fallbacks, plus overlapping groups.
import { Avatar, AvatarGroup } from '@reactloom/ui';Examples
Sizes and fallbacks
Initials use a stable colour per name.
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.
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
| Prop | Type | Default |
|---|---|---|
srcFalls back to initials when missing or broken. | string | — |
nameAccessible 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
| Prop | Type | Default |
|---|---|---|
max | number | — |
sizeApplied to all. | AvatarSize | 'md' |
moreLabel | (n: number) => string | “{n} more” |
aria-labelName 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.
| Attribute | Values |
|---|---|
[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.
| Attribute | Values |
|---|---|
[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.