Avatar
A picture of a person, with something to show in its place when there is no picture.
import { Avatar } from "antlitz";
API
| Prop | Type | Default |
|---|---|---|
| alt | string | — |
| radius | "none" | "sm" | "md" | "lg" | "full" | none |
| size | "sm" | "md" | "lg" | md |
| src | string | — |
| variant | "soft" | "outline" | "solid" | soft |
children are the fallback — initials, an icon — shown when src is missing
or fails to load. Without children the fallback is a silhouette.
alt is required. It names the avatar in every state, so a screen reader
hears the same name whether the photo or the initials are on screen. Pass an
empty string when the name is already written beside the avatar, and the
avatar is hidden from assistive technology.
Usage
export function Basic() {
return (
<Avatar src={PHOTO} alt="Ada Lovelace">
AL
</Avatar>
);
}Fallback

export function Fallback() {
return (
<>
<Avatar alt="Ada Lovelace">AL</Avatar>
<Avatar src="/does-not-exist.png" alt="Grace Hopper">
GH
</Avatar>
<Avatar alt="Unknown user" />
</>
);
}The first has no src, the second points at an image that does not exist,
and the third has neither a source nor children.
Avatar does not derive initials from alt. Names do not split into initials
the same way in every language, so the fallback is whatever you pass.
Variants
export function Variants() {
return VARIANTS.map((variant) => (
<Avatar key={variant} variant={variant} alt={variant}>
AL
</Avatar>
));
}Variants style the fallback. A loaded image covers the fill; the outline
border stays visible around it.
Sizes
export function Sizes() {
return SIZES.map((size) => (
<Avatar key={size} size={size} src={PHOTO} alt={size}>
AL
</Avatar>
));
}The sizes are 30, 38 and 46 pixels — the heights of Button's icon sizes —
so an avatar sits flush beside the controls in a toolbar.
export function Toolbar() {
return (
<div className="flex items-center gap-2">
<Button size="icon" variant="outline" aria-label="Notifications">
<Icon size={16}>
<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9" />
<path d="M10.3 21a1.94 1.94 0 0 0 3.4 0" />
</Icon>
</Button>
<Avatar src={PHOTO} alt="Ada Lovelace">
AL
</Avatar>
</div>
);
}Radius
export function Radius() {
return RADII.map((radius) => (
<Avatar key={radius} radius={radius} src={PHOTO} alt={radius}>
AL
</Avatar>
));
}The default is none, like everything else in the system. A square avatar
still reads as a person, so the shape carries no meaning that would justify an
exception the way it does for Radio and Switch.
Groups
export function Group() {
return (
<div className="flex -space-x-2">
<Avatar
radius="full"
src={PHOTO}
alt="Ada Lovelace"
className="ring-background ring-2"
>
AL
</Avatar>
<Avatar
radius="full"
alt="Grace Hopper"
className="ring-background ring-2"
>
GH
</Avatar>
<Avatar
radius="full"
variant="solid"
alt="Three more"
className="ring-background ring-2"
>
+3
</Avatar>
</div>
);
}A stack of avatars is a flex row with negative spacing and a ring in the page
colour to separate the overlaps. There is no AvatarGroup; the arrangement is
a handful of utilities.
Loading
The image is in the server-rendered HTML, layered over the fallback, which shows through until the picture arrives. Avatar is a client component only so that it can drop an image that fails.
It renders a plain img. An avatar is drawn at one small size, so the
optimisation worth having is a source already sized for it — ask your image
host for the pixel size times the device pixel ratio.