Avatar
A round portrait with an initial fallback while the image loads or when it fails.
import { Avatar } from "@arcadia/ui"Without an image an avatar is a monogram: the first letter of the first and the last word of the name, one letter at xs. Its tone is hashed from the name, one of blue, cyan, green, purple and pink, so a person keeps the same colour everywhere; never the beacon, yellow or red, which mean something else. The monogram also shows until an image has loaded, after a 300ms grace period so a fast image never flashes a letter first, and it stays if the image fails: Grace's image above is broken, and the row keeps its shape and colour. In a ListRow use xs, which fills the 20px leading slot exactly.
Examples
hue picks a tone instead of the hash (neutral is the quiet grey). rootStyle takes layout and these knobs: a size, and palette tokens for the monogram and its fill.
| Knob | Takes | Default | Sets |
|---|---|---|---|
Ref<Control | Space> | var(--control-md) | Width and height. | |
Paint | color-mix(in oklab | The monogram's fill: the tone over the card, opaque, so it reads the same on any surface. | |
Paint | color-mix(in oklab | The monogram's ink: the tone pulled toward the theme's ink (4.5:1 or more on its fill). |
The root is an img role named by name; the image and the monogram inside it are decorative, so a screen reader reads the person's name once whichever is showing. Every tone's ink clears 4.5:1 on its own fill in both themes.
Where the name is already written beside the avatar, as in the rows above, the reader hears it twice. That is usually fine for a list of people; for a dense list, wrap the avatar in an element with aria-hidden.
Avatar
namerequired- string
- Accessible name, and the source of the monogram and its tone.
src- string
size- "xs" | "sm" | "md" | "lg" | "xl"Default"md"
- 20 / 24 / 28 / 32 / 40.
hue- "auto" | "neutral" | "blue" | "cyan" | "green" | "purple" | "pink"Default"auto"
- The monogram's hue. Hashed from the name.
rootStyle- RootStyle<AvatarKnobs>
- Typed StyleX override: layout and the
--avatar-*knobs.
Rest props go to <span> props.