Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Data display

Avatar

Free12.3 KB gzipped

A 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

tsx
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.

tsx
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.

SR
PP
tsx
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.

JLSRPPAK
tsx
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

JLJLJLJLJLJL
CRS
tsx
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.

JLSRPPAK
tsx
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.

JLSRPPAK
tsx
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.

PP

Diego Ramos

tsx
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).

LF
JWMSPW
tsx
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

tsx
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

Avatar props
PropTypeDefault
src

Image URL. When it fails to load, the avatar falls back to initials, then to a user icon.

string—
alt

Text alternative for the image. Used as the accessible name (falls back to name). Pass alt="" with no name to make the avatar decorative.

string—
name

Person's name. Used for initials, colorFromName, and the accessible name when alt is not set.

string—
size

Size. xs 24px, sm 32px, md 40px, lg 48px, xl 64px, 2xl 96px. Inside an AvatarGroup, the group's size wins.

"xs""sm""md""lg""xl""2xl"—
shape

Corner shape.

"circle""rounded""square"—
tone

Fallback fill color (initials or icon). Ignored when colorFromName is set and a name is given.

"neutral""primary""accent""success""warning""danger""info"—
variant

Fallback fill style: soft (subtle fill) or solid (strong fill).

"soft""solid"—
colorFromName

Pick the fallback tone from a hash of name, so lists are colorful but stable.

boolean—
status

Presence dot at the bottom-end corner. Also appended to the accessible name, e.g. "Dana Hernandez (online)".

"online""away""busy""offline"—
statusLabel

Text for the status in the accessible name. Defaults to the status value ("online", "away", ...).

string—
borderedNew in 2.3.0

Draws 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 --avatar-border-color CSS variable (default --color-border-strong); set it to var(--color-surface) for a light frame on a photo banner.

boolean—
ring

Highlight ring (e.g. the active player). Visual only: also convey the state in text nearby or in aria-label.

boolean—
ringTone

Color of the highlight ring. Uses the tone's --color-*-border token.

"neutral""primary""accent""success""warning""danger""info"—
decorative

Hide the avatar from assistive technology. Use when the person's name is already visible next to the avatar.

boolean—
icon

Custom fallback icon shown when there is no image and no initials. Defaults to UserIcon.

ReactNode—
imgProps

Extra props for the inner <img> (e.g. loading, crossOrigin, referrerPolicy).

Omit<ComponentPropsWithRef<"img">, "src" | "alt">—
onImageStatusChange

Called 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.

AvatarGroup props
PropTypeDefault
size

Size applied to every avatar in the group (overrides each avatar's own size).

"xs""sm""md""lg""xl""2xl"—
shape

Default shape for avatars in the group. An avatar's own shape still wins.

"circle""rounded""square"—
max

Maximum number of avatars shown. Extra avatars collapse into a "+N" surplus avatar.

number—
spacing

How much avatars overlap: sm 15%, md 25%, lg 40% of the avatar size.

"sm""md""lg"—
surplusLabel

Accessible label for the surplus avatar. Defaults to and ${count} more.

(count: number) => string—
renderSurplus

Replace the default "+N" surplus avatar. Receives the hidden count and the hidden children.

(count: number, hidden: ReactNode[]) => ReactNode—
children

Avatars to stack.

ReactNode—
aria-label

Accessible name for the group, e.g. "Starting lineup".

string—
aria-labelledby

ID 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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 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

Roles and states
ElementRoleStates and properties
Avatarimgaria-label (the name); initials and image are hidden from screen readers
AvatarGroupgrouparia-label

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)