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
Fallback Chain
The avatar tries each fallback in order:
- Image (
srcprop) — rendered as<img> - Initials (
initialsprop) — centered text - Default icon — generic user silhouette SVG
Sizes
Shapes
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:
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. This produces a "double ring" presence indicator similar to Slack, Discord or iMessage — useful when you want the status to be visible at a glance without hunting for a tiny dot:
The ring scales subtly with avatar size so it stays visually balanced on every size variant:
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 role="status" and aria-label move from the dot <span> onto the avatar root so screen readers still announce the state once.
Width & Layout
Avatar dimensions are fixed by the size prop (sm = 32px, md = 40px, lg = 48px, xl = 64px). The avatar is always a perfect circle.
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.
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.
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.
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 |
size |
string | 'md' |
xs, sm, md, lg, xl |
shape |
string | 'circle' |
circle, square |
status |
string|null | null |
online, busy, away, offline |
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 (xs–xl) |
label |
string|null | null |
Accessible name for the group |
scope |
string|null | null |
Scoped personalization name |
Accessibility
- Always provide an
altprop. For<img>avatars, this becomes thealtattribute. 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 use
role="status"+aria-labelso screen readers announce the state ("Online", "Busy", etc.). - Initials are marked
aria-hidden="true"when analtis provided, preventing duplicate announcements.
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" />
{{-- Decorative (e.g. in a list with visible name next to it): --}}
<x-wirekit::avatar initials="JS" />
Keyboard Interaction
This component is purely presentational and does not respond to keyboard input.
Pitfalls
- Don't use an avatar without
alt. Decorative use is fine withalt=""; identifying use needs the person's name inaltor it's not announced.
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 / --color-wk-warning / --color-wk-danger / --color-wk-text-muted |
Status colors |
--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'],
],