Avatar
Who something belongs to, as a circle: a person's picture or initials, an icon, or a brand's logo. Alone, or stacked in a group.
<Avatar name="Maya Okafor" /><AvatarGroup> <Avatar name="Jonas Weber" /> <Avatar name="Priya Raman" /> <Avatar name="Lucas Ferreira" /> <Avatar name="Sofia Marchetti" /></AvatarGroup>Installation
import { Avatar, AvatarGroup } from "@dome-systems/ds-dashboard/components";Anatomy
A circle in the name's color holding a picture, up to two initials, or an icon; or a neutral gray circle, for a brand's logo or withcolored off. A 1px edge inside the circle sits over all of them: dark in light, light in dark. In a group every avatar takes the group's size, and with the size come the overlap and the 2px gap.
| size | Circle | Initials | Icon or logo | Overlap in a group |
|---|---|---|---|---|
lg | 36px | 14.4px | 18px | 8px |
md | 32px | 12.8px | 16px | 7px |
sm | 28px | 11.2px | 14px | 6px |
xs | 24px | 9.6px | 12px | 5px |
xxs | 20px | 8px | 10px | 4px |
xxxs | 16px | 6.4px | 10px | 3px |
Sizes
Six, named as the Button's: md is 32px, as tall as a medium button. lg and xxxs are the Avatar's own.
<Avatar name="Maya Okafor" size="lg" /><Avatar name="Maya Okafor" /><Avatar name="Maya Okafor" size="sm" /><Avatar name="Maya Okafor" size="xs" /><Avatar name="Maya Okafor" size="xxs" /><Avatar name="Maya Okafor" size="xxxs" />The name
The initials and the color are read from the name: the same name is the same color everywhere. One word gives one letter.
<Avatar name="Maya Okafor" /><Avatar name="Jonas Weber" /><Avatar name="jane@acme.com" />An icon
What something without initials shows, as a workspace or an organization. The color still comes from the name.
<Avatar name="Acme" icon={Building} /><Avatar name="Design preview" icon={Squares} size="xs" />Without the name's color
colored off: a neutral gray circle, its icon or initials in the secondary text color. For an avatar whose color would say nothing, as an icon standing in for a missing logo.
<Avatar name="Custom model" icon={Brain} colored={false} /><Avatar name="Maya Okafor" colored={false} size="xs" />A logo
A brand's logo from @dome-systems/ds-dashboard/logos, as a model's provider. It keeps its own colors on the neutral gray circle, whatever colored says. An avatar takes an icon or a logo, never both.
<Avatar name="Anthropic" logo={AnthropicLogo} /><Avatar name="OpenAI" logo={OpenAiLogo} size="xs" />A picture
Until it has loaded, and if it fails, the initials, the icon or the logo show.
<Avatar name="Maya Okafor" src="/maya.jpg" />A status dot
The Status dot, on the circle's edge with a gap cut around it. Its size comes from the avatar's; dotPlacement picks the corner.
<Avatar name="Maya Okafor" dot={{ color: "success" }} /><Avatar name="Jonas Weber" size="xs" dot={{ color: "warning" }} dotPlacement="bottom-right" /><Avatar name="Priya Raman" size="xxs" dot={{ color: "error" }} /><Avatar name="Lucas Ferreira" size="xxxs" dot={{ color: "success" }} />A group
Each avatar sits over the one before it, which is cut where the next one sits. The gap is empty, so any fill shows through it.
<AvatarGroup size="xs"> <Avatar name="Maya Okafor" /> <Avatar name="Jonas Weber" /> <Avatar name="Priya Raman" /></AvatarGroup>The count
Three avatars at most, then how many more. total is for a group handed only the first few of a longer list.
<AvatarGroup size="xs">{five}</AvatarGroup><AvatarGroup size="xs" total={13}>{three}</AvatarGroup><AvatarGroup size="xxxs" total={13}>{three}</AvatarGroup>In the dashboard
The sidebar's signed-in user
At xxs, before the email. While impersonating, a red border takes the outer 2px and the avatar is xxxs.
components/layout/user-menu.tsx
A judge's card
At lg, before the judge's name.
components/judges/judge-vote-card.tsx
A filter value's mark
The Filters size the mark's slot themselves (20px in a menu row, 16 in a chip), so it takes the face alone.
ds/components/filters.tsx
Accessibility
An avatar or a group is decoration: it is hidden from a screen reader, because the name is written beside it. One that stands alone takes aria-label like any element, and is then announced as an image with that name.
The initials are white on the name's color, the same in light and dark: 4.5 to 1 or better for every one of the twenty colors.
API Reference
Avatar
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | — | Whose it is. The initials and the color are read from it. |
src | string | — | A picture. Until it has loaded, and if it fails, the initials, the icon or the logo show. |
icon | IconComponent | — | An icon in place of the initials, stroke or fill. Not with logo. |
logo | LogoComponent | — | A brand's logo in place of the initials, in its own colors, always on the neutral circle. Not with icon. |
colored | boolean | true | The circle in the name's color. Off, a neutral gray, its initials or icon in the secondary text color. |
size | "lg" | "md" | "sm" | "xs" | "xxs" | "xxxs" | "md" | The circle's diameter. In a group, the group's. |
dot | StatusDotSpec | — | A Status dot on the circle's edge, with a gap cut around it: its color, its size (the avatar's gives one), its gap, a pulse. |
dotPlacement | "top-right" | "bottom-right" | "bottom-left" | "top-left" | "top-right" | The corner the dot sits toward. |
tooltip | boolean | AvatarTooltip | — | Shown on hover: on for the name, or the Tooltip's settings (side, delay…) with children in place of the name. In a group with a tooltip, on unless set. |
AvatarGroup
| Prop | Type | Default | Description |
|---|---|---|---|
size | "lg" | "md" | "sm" | "xs" | "xxs" | "xxxs" | "md" | One size for every avatar in the group. With it come the overlap and the gap. |
max | number | 3 | How many avatars are drawn before the count. |
total | number | — | How many there are in all, when the group is handed only the first few. |
children | ReactNode | — | The avatars, each an Avatar. A host that hands faces in (the Filter chip) may give an AvatarFace each: every place in a group has the group's size, and shows the face's name when the group's tooltip is on. |
tooltip | boolean | Omit<AvatarTooltip, "children"> | — | On, each avatar shows its name on hover and the count lists who it stands for (ten names at most, then how many more). Moving along the stack, the tooltip slides from one to the next. |
AvatarFace
The circle alone, filling the box it is given. For a component that sizes its own slot, as a filter value's mark. A screen uses Avatar.
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | — | Whose it is. The initials and the color are read from it. |
src | string | — | A picture. Until it has loaded, and if it fails, the initials, the icon or the logo show. |
icon | IconComponent | — | An icon in place of the initials, stroke or fill. Not with logo. |
logo | LogoComponent | — | A brand's logo in place of the initials, in its own colors, always on the neutral circle. Not with icon. |
colored | boolean | true | The circle in the name's color. Off, a neutral gray, its initials or icon in the secondary text color. |
iconSize | number | 14 | The icon's or logo's size in px, since the face does not know its own. |
Rules
Written down
The sizes are the Button's
An avatar is as tall as the button of its size: md 32, sm 28, xs 24, xxs 20. lg (36) and xxxs (16) are added at either end.
From ds/README.md (Avatar) and ds/lib/avatar.ts.
A group's gap is cut, never painted
The avatar behind is masked where the next one sits. A ring in a surface's color would show as an edge on any other fill.
From ds/README.md (Avatar) and ds/components/avatar.tsx.
Three avatars, then a count
The count is one more circle, the avatars' size, in a neutral gray. Two digits make it a pill of the same height.
From ds/README.md (Avatar).
The dot is the Status dot
The prop is dot, as on a Button or a Badge. It sits on the circle's edge, top right unless told otherwise, and the avatar is cut around it with a mask, never ringed.
In a group the dot stays whole: it is drawn over the avatars beside it, and they are cut around it as its own avatar is.
From ds/README.md (Avatar) and ds/components/status-dot.tsx.
The initials are read, never typed
name gives the letters and one of twenty colors, the same pick the website makes for that name.
From ds/components/avatar.tsx and ds/lib/avatar-palette.ts.
Open questions
Do words stay beside a group's count?
OpenThe filter chip writes "5 owners" after its avatars today, and draws no count. With the count circle the words may go. Not decided.
shadcn's group shows the count circle alone.
Do organizations and workspaces take the Avatar?
OpenThe icon is there for them. The context switcher keeps its own tiles for now.
Not compared.