Avatar
Compact identity marker. Falls back image → initials → user icon, with a deterministic background hue derived from the name.
Preview
<Avatar name="Ada Lovelace" /> Sizes
<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
<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. |
initials | string | — | Explicit initials, overriding the first+last derivation from name. For callers that carry their own rule — esa-header-nav takes the first letter of every word capped at two, so "Mary Jane Watson" is MJ there and MW by default here. |
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,
split by blast radius: the hooks that belong to this component,
then the shared and system tokens it consumes alongside everything else. 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.
Type roles it names
This component does not set a size, weight, face or tracking of its own — it names a composite, and the composite carries all five. A composite is a class rather than a token, so none of it appears in the tables below; re-theme text by re-pointing the token family, not by editing the component.
| Role | Re-point | Reach |
|---|---|---|
.typography-label-2xs-strong |
| only here |
.typography-label-md-strong |
| +3 more componentsesa-empty-state, esa-error-summary, esa-header-nav |
.typography-label-xs-strong |
| +1 more componentesa-empty-state |
.typography-title |
| +4 more componentsesa-confirm-dialog, esa-dialog, esa-empty-state, esa-side-dialog |
Wired to this component
No other component reads these — re-point them and esa-avatar is the
only thing that moves.
| Token | Tier | Resolves to |
|---|---|---|
--avatar-size-lg | component | 56px |
--avatar-size-md | component | 40px |
--avatar-size-sm | component | 28px |
--avatar-size-xs | component | 20px |
Shared tokens it reads
Owned by a family or by the semantic layer. Still overridable — but scope the
override (esa-foo { --form-border-color: … }) unless you mean to move
everything that reads it. Reach says what else that is.
| Token | Reach | Resolves to |
|---|---|---|
--color-content-default-knockout | semantic every component | #fcfcfc via --color-gray-1 |
--radius-md | semantic every component | 0.5rem via --radius-200 |
--radius-pill | semantic every component | 9999px via --radius-full |
--typography-label-2xs-strong-font-size | semantic every component | clamp(0.5rem, 0.44rem + 0.3vw, 0.625rem) via --font-size-050 |
--typography-label-md-strong-font-size | semantic every component | clamp(0.75rem, 0.66rem + 0.44vw, 0.9375rem) via --font-size-200 |
--typography-label-xs-strong-font-size | semantic every component | clamp(0.625rem, 0.56rem + 0.32vw, 0.75rem) via --font-size-100 |
--typography-title-font-size | semantic every component | clamp(1rem, 0.88rem + 0.6vw, 1.25rem) via --font-size-400 |