Canvas Design System
Main Site Tokens

Avatar

User avatars with image support and initials fallback. Includes status indicators and custom color options.

When to Use

Use Avatar when: Representing a user or team member in navigation bars, comments, participant lists, or user profiles. The initials fallback ensures a consistent look even without a photo.
Don't use when: Displaying a generic icon or logo — use an icon or image instead. For decorative thumbnails unrelated to a person, use a standard image element.

Sizes

AB
BS
CW
DL
EJ
<?= ws_avatar('Alice Brown', ['size' => 'xs']) ?>
<?= ws_avatar('Bob Smith', ['size' => 'sm']) ?>
<?= ws_avatar('Carol White', ['size' => 'md']) ?>
<?= ws_avatar('David Lee', ['size' => 'lg']) ?>
<?= ws_avatar('Eve Johnson', ['size' => 'xl']) ?>

With Images

When an image URL is provided, it replaces the initials fallback.

John Doe
Jane Smith
Alex Johnson
<?= ws_avatar('John Doe', ['image' => '/path/to/avatar.jpg']) ?>

With Status

A coloured dot indicates online, offline, or busy status.

OU
OU
BU
<?= ws_avatar('User', ['status' => 'online']) ?>
<?= ws_avatar('User', ['status' => 'offline']) ?>
<?= ws_avatar('User', ['status' => 'busy']) ?>

Custom Colors

Override the default background colour for initials avatars. Useful for colour-coding by role or team.

PU
CU
RU
<?= ws_avatar('Plan User', ['color' => '#0284C7']) ?>

With Ring

Ring User
RI
<?= ws_avatar('User', ['ring' => true]) ?>

Parameters

ParameterTypeDefaultDescription
$namestringUser name (used for initials fallback and title)
imagestringnullImage URL
sizestringmdxs | sm | md | lg | xl
colorstringnullCustom background colour (hex) for initials
ringboolfalseShow focus/highlight ring
statusstringnullonline | offline | busy
idstringnullElement ID
classstring''Additional CSS classes
attrsarray[]Extra HTML attributes

Anatomy

.ws-avatar — Outer container <div>
.ws-avatar__image<img> element (when image provided)
.ws-avatar__initials — Initials text (fallback)
.ws-avatar__status — Status indicator dot

CSS Classes

ClassPurpose
.ws-avatarBase avatar styles
.ws-avatar--xs / --sm / --md / --lg / --xlSize modifiers
.ws-avatar--initialsApplied when showing initials (no image)
.ws-avatar--ringFocus/highlight ring
.ws-avatar__status--onlineGreen status dot
.ws-avatar__status--offlineGrey status dot
.ws-avatar__status--busyRed status dot
.ws-avatar-groupOverlapping avatar stack

Files

FilePurpose
includes/components/helpers.phpws_avatar() helper function
includes/components/avatar.phpAvatar template
includes/components/components.cssAvatar CSS (.ws-avatar rules)