Data display
Avatar
Free12.3 KB gzippedA person's photo (src), with a fallback chain of image, initials (from name), then a user icon, so it always shows something. Supports a border, a presence status dot, a highlight ring, and stacking in an AvatarGroup.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report
Import
import { Avatar, AvatarGroup } from "@vjdesigns/vjdesigns-ui";
Importing only Avatar adds about 12.3 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Photos
src shows a photo, named by alt. If it fails to load, the avatar falls back to initials from name, then to an icon, so it always shows something. The last one's file doesn't exist.

import { Avatar, Flex } from "@vjdesigns/vjdesigns-ui";
export function Photos() {
return (
<Flex gap={3} align="center" wrap="wrap" justify="center">
<Avatar src="/docs/portrait-jordan.svg" alt="Jordan Lee" size="lg" />
<Avatar src="/docs/portrait-sam.svg" alt="Sam Rivera" size="lg" />
<Avatar src="/docs/portrait-priya.svg" alt="Priya Patel" size="lg" status="online" />
<Avatar src="/docs/portrait-alex.svg" alt="Alex Kim" size="lg" shape="rounded" />
<Avatar src="/docs/missing-photo.jpg" name="Morgan Chen" size="lg" colorFromName />
</Flex>
);
}
Bordered
bordered draws a border around a photo, initials or the icon. It works with ring and inside a group. Set the --avatar-border-color CSS variable to change its color, for example a light frame on a profile banner.
import { type CSSProperties } from "react";
import { Avatar, AvatarGroup, Flex, Stack } from "@vjdesigns/vjdesigns-ui";
export function Bordered() {
return (
<Stack gap={6} align="center" style={{ width: "100%" }}>
<Flex gap={4} align="center" wrap="wrap" justify="center">
<Avatar src="/docs/portrait-jordan.svg" alt="Jordan Lee" size="xl" bordered />
<Avatar name="Sam Rivera" tone="primary" size="xl" bordered />
<Avatar aria-label="Guest" size="xl" bordered />
<Avatar src="/docs/portrait-priya.svg" alt="Priya Patel, presenting" size="xl" bordered ring />
</Flex>
<div
style={{
display: "flex",
alignItems: "center",
boxSizing: "border-box",
width: "100%",
maxWidth: "24rem",
padding: "var(--space-4) var(--space-5)",
borderRadius: "var(--radius-xl)",
background: "var(--color-primary)",
}}
>
<Avatar
src="/docs/portrait-alex.svg"
alt="Alex Kim"
size="2xl"
bordered
style={{ "--avatar-border-color": "var(--color-surface)" } as CSSProperties}
/>
</div>
<AvatarGroup size="lg" aria-label="Bordered lineup">
<Avatar src="/docs/portrait-jordan.svg" alt="Jordan Lee" bordered />
<Avatar src="/docs/portrait-sam.svg" alt="Sam Rivera" bordered />
<Avatar name="Priya Patel" colorFromName bordered />
</AvatarGroup>
</Stack>
);
}
Initials
Without an image, avatars show initials from name. colorFromName gives each person a stable color.
import { Avatar, Flex, UserIcon } from "@vjdesigns/vjdesigns-ui";
export function Initials() {
return (
<Flex gap={3} align="center" wrap="wrap" justify="center">
<Avatar name="Jordan Lee" colorFromName />
<Avatar name="Sam Rivera" colorFromName />
<Avatar name="Priya Patel" colorFromName />
<Avatar name="Alex Kim" variant="solid" tone="primary" />
<Avatar aria-label="Guest" icon={<UserIcon />} />
</Flex>
);
}
Sizes and shapes
import { Avatar, Flex, Stack } from "@vjdesigns/vjdesigns-ui";
export function SizesAndShapes() {
return (
<Stack gap={4} align="center">
<Flex gap={3} align="center">
{(["xs", "sm", "md", "lg", "xl", "2xl"] as const).map((size) => (
<Avatar key={size} name="Jordan Lee" size={size} colorFromName />
))}
</Flex>
<Flex gap={3} align="center">
<Avatar name="Circle" shape="circle" tone="primary" />
<Avatar name="Rounded" shape="rounded" tone="primary" />
<Avatar name="Square" shape="square" tone="primary" />
</Flex>
</Stack>
);
}
Status
status adds a presence dot, which is included in the accessible name.
import { Avatar, Flex } from "@vjdesigns/vjdesigns-ui";
export function Status() {
return (
<Flex gap={4} align="center">
<Avatar name="Jordan Lee" status="online" colorFromName size="lg" />
<Avatar name="Sam Rivera" status="away" colorFromName size="lg" />
<Avatar name="Priya Patel" status="busy" colorFromName size="lg" />
<Avatar name="Alex Kim" status="offline" colorFromName size="lg" />
</Flex>
);
}
Group
AvatarGroup overlaps avatars and collapses the rest into a "+N" count after max.
import { Avatar, AvatarGroup } from "@vjdesigns/vjdesigns-ui";
export function Group() {
return (
<AvatarGroup max={4} size="md" aria-label="Project members">
{["Jordan Lee", "Sam Rivera", "Priya Patel", "Alex Kim", "Morgan Chen", "Taylor Brooks"].map((name) => (
<Avatar key={name} name={name} colorFromName ring />
))}
</AvatarGroup>
);
}
Accessibility
An avatar is named by name (or alt), and its status is part of the name ("Priya Patel, in a meeting"), so it isn't shown by color alone. When the name is already written beside it, decorative hides the avatar so the name isn't read twice.
Diego Ramos
import { Avatar, Flex, Text } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Flex gap={8} align="center" wrap="wrap">
<Avatar name="Priya Patel" status="busy" statusLabel="in a meeting" />
<Flex align="center" gap={3}>
<Avatar name="Diego Ramos" decorative />
<Text weight="semibold">Diego Ramos</Text>
</Flex>
</Flex>
);
}
Translated
The status words ("online") and the surplus avatar's name ("and 2 more") come from the locale (German here).
import {
Avatar,
AvatarGroup,
Flex,
LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import de from "@vjdesigns/vjdesigns-ui/locales/de";
export function Translated() {
return (
<LocaleProvider locale="de" messages={de}>
<Flex gap={8} align="center" wrap="wrap">
<Avatar name="Lena Fischer" status="online" />
<AvatarGroup max={3} aria-label="Teammitglieder">
<Avatar name="Jonas Weber" />
<Avatar name="Mia Schulz" />
<Avatar name="Paul Wagner" />
<Avatar name="Emma Becker" />
<Avatar name="Ben Hoffmann" />
</AvatarGroup>
</Flex>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Photos

import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Photos is the "Photos" example above.
<LocaleProvider locale="ar" messages={ar}>
<Photos />
</LocaleProvider>
API reference
Avatar
| Prop | Type | Default |
|---|---|---|
srcImage URL. When it fails to load, the avatar falls back to initials, then to a user icon. | string | — |
altText alternative for the image. Used as the accessible name (falls back to | string | — |
namePerson's name. Used for initials, | string | — |
sizeSize. | "xs""sm""md""lg""xl""2xl" | — |
shapeCorner shape. | "circle""rounded""square" | — |
toneFallback fill color (initials or icon). Ignored when | "neutral""primary""accent""success""warning""danger""info" | — |
variantFallback fill style: | "soft""solid" | — |
colorFromNamePick the fallback tone from a hash of | boolean | — |
statusPresence dot at the bottom-end corner. Also appended to the accessible name, e.g. "Dana Hernandez (online)". | "online""away""busy""offline" | — |
statusLabelText for the status in the accessible name. Defaults to the status value ("online", "away", ...). | string | — |
borderedNew in 2.3.0Draws a border around the avatar, e.g. to set a photo apart from a busy background or a cover image. Decorative. Its color is the | boolean | — |
ringHighlight ring (e.g. the active player). Visual only: also convey the state in text nearby or in | boolean | — |
ringToneColor of the highlight ring. Uses the tone's | "neutral""primary""accent""success""warning""danger""info" | — |
decorativeHide the avatar from assistive technology. Use when the person's name is already visible next to the avatar. | boolean | — |
iconCustom fallback icon shown when there is no image and no initials. Defaults to | ReactNode | — |
imgPropsExtra props for the inner | Omit<ComponentPropsWithRef<"img">, "src" | "alt"> | — |
onImageStatusChangeCalled with the new image status when the image loads or fails. | (status: AvatarImageStatus) => void | — |
Also accepts native <span> attributes, plus className, style and ref.
AvatarGroup
Overlapping stack of avatars in a labelled role="group". Avatars beyond max collapse into a "+N" surplus avatar with an accessible label.
| Prop | Type | Default |
|---|---|---|
sizeSize applied to every avatar in the group (overrides each avatar's own | "xs""sm""md""lg""xl""2xl" | — |
shapeDefault shape for avatars in the group. An avatar's own | "circle""rounded""square" | — |
maxMaximum number of avatars shown. Extra avatars collapse into a "+N" surplus avatar. | number | — |
spacingHow much avatars overlap: | "sm""md""lg" | — |
surplusLabelAccessible label for the surplus avatar. Defaults to | (count: number) => string | — |
renderSurplusReplace the default "+N" surplus avatar. Receives the hidden count and the hidden children. | (count: number, hidden: ReactNode[]) => ReactNode | — |
childrenAvatars to stack. | ReactNode | — |
aria-labelAccessible name for the group, e.g. "Starting lineup". | string | — |
aria-labelledbyID of a visible element that names the group. | string | — |
Also accepts native <div> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Avatar targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
Not focusable, so there's no keyboard interaction of its own.
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Avatar | img | aria-label (the name); initials and image are hidden from screen readers |
AvatarGroup | group | aria-label |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |