Avatar
Compact identity marker. Falls back image → initials → user icon, with a deterministic background hue derived from the name.
Preview
AL
<Avatar name="Ada Lovelace" /> Sizes
AL AL AL AL
<Avatar name="Ada Lovelace" size="xs" />
<Avatar name="Ada Lovelace" size="sm" />
<Avatar name="Ada Lovelace" size="md" />
<Avatar name="Ada Lovelace" size="lg" /> Shapes
GH GH
<Avatar name="Grace Hopper" shape="circle" />
<Avatar name="Grace Hopper" shape="square" /> Fallbacks
The background hue is hashed from name, so each person gets a stable, distinct color. Resolution order is image → initials → user icon.
<Avatar src="https://i.pravatar.cc/100?img=12" name="Photo User" />
<Avatar name="Alan Turing" />
<Avatar name="Single" />
<Avatar /> API
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | '' | Used to derive initials and a deterministic background hue. |
src | string | '' | Image URL. When set, renders the photo instead of initials. |
icon | string | '' | Lucide icon name for an icon fallback (defaults to a user glyph). |
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Avatar diameter (20 / 28 / 40 / 56px). |
shape | 'circle' | 'square' | 'circle' | Fully rounded or rounded-square. |
Accessibility
- Image fallback uses
name(or "Avatar") as itsalttext. - The icon fallback is
aria-hidden— pair the avatar with a visible name nearby for screen readers. - Content is non-selectable (
user-select: none) so initials don't interfere with text selection.
Theming surface
Every public token this component reads, extracted from its source at build time.
The Resolves to column walks each token's real lineage —
component → semantic → primitive → raw value — so you
can see exactly where re-pointing it lands. A spoke re-skins by overriding these in
its theme-<slug>.css; component internals are never edited. No
hook for what you need? File it with /request-lego.
| Token | Tier | Resolves to |
|---|---|---|
--avatar-radius | component | 9999px via --radius-full |
--avatar-size-lg | component | 56px |
--avatar-size-md | component | 40px |
--avatar-size-sm | component | 28px |
--avatar-size-xs | component | 20px |
--avatar-text-color | component | #fcfcfc via --color-text-inverse → --color-gray-1 |
--radius-200 | primitive | 0.5rem |