Skip to main content
  1. Docs
  2. Components
  3. Data display

Avatar

A person, or an organisation, application or tenant: their photo or logo, or their initials.

Import
@qeetrix/react
Status
StableSince 0.0.2
Renders
<span role="img">Server-rendered
Tested
WCAG 2.2 AAaxe on every pull request

01

Import

avatar.tsx
// From the package: a build keeps only what it uses.
import { Avatar } from "@qeetrix/react";

// Or from its own path.
import { Avatar } from "@qeetrix/react/avatar";

02

Props

And every native attribute of the element it renders.

PropTypeDefaultWhat it does
namestringrequiredThe text alternative, and the initials: the first word's letter and the last's. A legal form (Pvt Ltd, LLP, Inc) doesn't count.
srcstring—The photo or logo; the initials show while it loads, and if it fails.
size"sm" | "md" | "lg" | "xl""md"24, 32, 40 or 48px.
shape"circle" | "square""circle"Circle for a person; square, with a control's corners, for anything else.
statusAvatarStatus: { label: string; tone?: AvatarStatusTone }—A dot on the bottom-end corner, 8 to 14px with the size. label is read with the name: "Priya Sharma, Online".
status.toneAvatarStatusTone: "neutral" | "brand" | "info" | "success" | "warning" | "danger""neutral"Badge's tones: success for online, warning for away.
decorativebooleanfalseThe name is shown beside it: hidden from assistive technology, its status too.

03

Parts

Each part carries a data-slot, for tests and placement.

data-slotElementWhat it is
avatar<span role="img">data-size, data-shape, data-status; aria-label.
avatar-image<img alt="">The photo, once loaded.
avatar-fallback<span>The initials, aria-hidden.
avatar-status<span>The status dot, aria-hidden; data-tone.

04

In a list

Beside the name, the avatar adds nothing to hear: AvatarItem hides it and keeps the two lines a md avatar's height.

member.tsx
import { AvatarItem } from "@qeetrix/react/experimental";

<AvatarItem name={user.name} description={user.email} src={user.photoUrl} />

05

Presence from your data

Map each state to an AvatarStatus once, and pass it.

presence.tsx
import { Avatar, type AvatarStatus } from "@qeetrix/react";

const PRESENCE: Record<Presence, AvatarStatus> = {
  online: { label: "Online", tone: "success" },
  away: { label: "Away", tone: "warning" },
  offline: { label: "Offline" },
};

<Avatar name={user.name} src={user.photoUrl} status={PRESENCE[user.presence]} />
Next — AvatarAccessibility