Skip to main content
Copy for LLM

Avatar

A user profile image with automatic fallback to initials or a default icon. Avatars support five sizes, two shapes, and optional status indicators.

Basic Usage

With image
Jane Smith
With initials
Jane Smith
Default fallback icon

Fallback Chain

The avatar tries each fallback in order:

  1. Image (src prop) — rendered as <img>
  2. Initials (initials prop) — centered text
  3. Default icon — generic user silhouette SVG

Sizes

All sizes
Ada Lovelace Ada Lovelace Ada Lovelace Ada Lovelace Ada Lovelace

Shapes

Circle and square
JD JD

Status Indicators

Add a status dot to indicate user presence. The dot sits on the bottom-right corner with a ring matching the page background, and each state has a shape of its own as well as a color: online is a filled dot, busy a dot crossed by a bar, away a half-filled dot and offline a hollow one:

Status dots (default)
Ada Lovelace Grace Hopper Alan Turing Katherine Johnson

Full Status Ring

Set status-variant="ring" to replace the corner dot with a colored ring that surrounds the entire avatar, separated from the image by a thin gap in the page background. It makes the status visible at a glance, without hunting for a small dot. The ring has a shape per state too: solid when online, doubled when busy, dotted when away and dashed when offline:

Status ring — all four states
Ada Lovelace Online Grace Hopper Busy Alan Turing Away Katherine Johnson Offline

The ring scales subtly with avatar size so it stays visually balanced on every size variant:

Status ring across sizes
Ada Lovelace Online Ada Lovelace Online Ada Lovelace Online Ada Lovelace Online Ada Lovelace Online

When status-variant="ring", the corner dot is omitted — the colored ring on the container already conveys the presence state, and stacking both would be visually noisy. The name moves with it: instead of the dot's aria-label, the avatar carries a visually hidden text span holding the same word, so screen readers still announce the state once.

Width & Layout

Avatar dimensions are fixed by the size prop (xs = 24px, sm = 32px, md = 40px, lg = 48px, xl = 64px). The outline is a perfect circle by default; shape="square" swaps it for --radius-wk-md, which is the pair previewed above.

Deterministic Color From Initials

Add from-initials to derive a stable background color from the initials hash — the same person always gets the same color. The palette pairs an AA-contrast background with white text and is theme-independent.

Avatars colored from initials
AB MP LK SR

The same palette is available in PHP, so a custom chip or inline badge can match an avatar without rendering one:

use Pushery\WireKit\WireKit;

// Returns ['bg' => 'oklch(...)', 'fg' => '#fff'] for the same initials the component hashes.
$palette = WireKit::avatarPaletteFor('AB');

With Name & Detail

Compose an avatar with a name and a secondary line (role, email, handle) using Row and Stack — the canonical "user identity" cell for menus, tables, and comment headers.

Avatar with name and detail
JD

Jane Doe

Product Designer

Avatar Group

Stack multiple avatars into an overlapping group with <x-wirekit::avatar.group>. Each avatar is ringed in the surface color so the discs read as distinct. Set :remaining for a trailing "+N" overflow chip, and label for the group's accessible name. Match the group's size to the avatars you place inside it.

An avatar that the next one overlaps sets its initials in the part of its disc that stays visible, so the next disc never covers a letter. Groups in xs and sm overlap a fifth of the disc, larger ones 0.6rem. To change the overlap, set --wk-avatar-group-overlap on the group, and the initials follow it. At xs two wide letters such as "MW" fill nearly the whole disc and lose their outer edges in a stack, so one initial reads better at that size.

Overlapping avatar group with overflow count
AB MP LK
Avatar group sizes
AB MP LK
AB MP

Props

Prop Type Default Description
src string|null null Image URL
alt string|null null Accessible name (for images and initials/icon fallbacks)
initials string|null null Text shown when no src is provided
fromInitials bool false With initials set and no src, derive the background color deterministically from the initials, so the same person always gets the same color. The palette pairs an AA-contrast background with white text and is theme-independent
size string 'md' xs, sm, md, lg, xl
shape string 'circle' circle, square
status string|null null online, busy, away, offline
statusVariant string 'dot' How the status reads: dot (a corner dot) or ring (a ring around the whole avatar — more prominent, which is what a dense roster wants). Ignored when status is null
scope string|null null Scoped personalization name

<x-wirekit::avatar.group>

Prop Type Default Description
remaining int|null null Renders a trailing "+N" overflow chip when greater than 0
size string 'md' Sizes the overflow chip to match the avatars, and sets how far they overlap (xs–xl)
label string|null null Accessible name for the group
scope string|null null Scoped personalization name

Accessibility

  • Give alt the person's name wherever the avatar identifies someone. For <img> avatars, this becomes the alt attribute. For initials/icon fallbacks, it's rendered as visually hidden text (sr-only) so screen readers announce the person's name, not just their initials.
  • Status indicators are named, and the name is translated. The dot carries role="img" plus an aria-label — an icon that conveys information, not a live region, so it is read wherever the avatar itself is read rather than only at the moment it appears. The ring variant uses visually hidden text instead. The four words ("Online", "Busy", "Away", "Offline") come from WireKit's translation catalog and follow your application's locale.
  • The dot and the ring tell the four states apart by shape as well as by color, as WCAG 1.4.1 asks: a filled, a barred, a half-filled and a hollow dot, or a solid, a double, a dotted and a dashed ring. The colors are the text tones of their intents, at 3:1 or more against the page. Where the state matters to the reader, showing it as text beside the name still helps.
  • Initials are marked aria-hidden="true" whenever alt is given. A name replaces them, and alt="" marks the avatar decorative, as it marks an image. That is the choice beside a visible name: the initials are skipped and a status is still read.

Accessibility examples

{{-- Good: clear identity --}}
<x-wirekit::avatar src="/users/jane.jpg" alt="Jane Smith" />

{{-- Good: name announced via alt, initials hidden --}}
<x-wirekit::avatar initials="JS" alt="Jane Smith" />

{{-- Beside a visible name: the initials are skipped, the status is still read --}}
<x-wirekit::avatar initials="JS" alt="" status="online" />

Keyboard Interaction

This component is purely presentational and does not respond to keyboard input.

Pitfalls

  • Don't use an identifying avatar without alt. Without it, an image is decorative and initials are read as letters, not as a name. Beside a visible name, give it alt="" instead: the initials are skipped and a status is still read.

Design Tokens

Token Purpose
--color-wk-bg-muted Fallback background (initials + icon)
--color-wk-text Initials text color
--color-wk-text-muted Default icon color
--color-wk-border-subtle Avatar border
--color-wk-success-text / --color-wk-warning-text / --color-wk-danger-text / --color-wk-text-muted Status colors, the tones that hold 3:1 as a graphic
--color-wk-bg-elevated Status dot ring color
--radius-wk-md Square avatar radius

Customization

Override defaults in config/wirekit.php:

'components' => [
    'avatar' => ['size' => 'lg', 'shape' => 'square'],
],

Updated in WireKit v2.74.0 (2026-11-24)

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store