Avatar
A person or a thing, at a glance. An image when there is one, initials when there is not.
![]()
Use it
<x-ds::avatar :name="$user->name" :src="$user->avatar_url" />
<x-ds::avatar name="Ada Lovelace" size="sm" />
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
name | string | — | Supplies the initials and the accessible name. |
src | string | — | Image URL. Without one, the initials are the avatar. |
initials | string | — | Letters of your own instead of the first and last word of name, upper-cased. |
size | xs sm md lg xl | md | 24 / 32 / 40 / 48 / 64px. xl is for a profile page and avatar upload. |
square | bool | false | For a company, project or file. |
decorative | bool | false | Hides it from screen readers. |
status | online away busy offline | — | A dot on the corner. See Status. |
sm (32px) matches the small control height, so an avatar sits level with a
small button in a table row without a nudge.
Round or square
Round is a person. square is a company, a project or a file — a circle
reads as a person, and a logo in a circle gets its corners eaten.
Initials
Taken from the first and last word, so "Ada King Lovelace" is AL — the middle name is the part nobody uses. Multi-byte names are handled correctly.
With neither src nor name, it renders a placeholder mark rather than an
empty circle.
Status
<x-ds::avatar :name="$user->name" status="away" />
A dot on the bottom corner, ringed in the ground colour. Each status is a
shape as well as a colour: online solid, away half full, busy
barred, offline hollow. Its word is part of the avatar's name ("Ada
Lovelace, away"), and hidden with it when the avatar is decorative. For who
is here now, with activities and a live list, use
presence stack.
Accessibility
Use decorative whenever the name is written next to the avatar — which is
most of the time. A row that announces "Ada Lovelace, Ada Lovelace" is worse
than one that announces it once.
<span class="flex items-center gap-3">
<x-ds::avatar :name="$user->name" :decorative="true" size="sm" />
<span>{{ $user->name }}</span>
</span>
Don't
- Don't use it as a button. Wrap it in one.
- Don't derive the colour from the name. A hash-to-hue avatar is nine unmanaged colours arriving through the back door.
- Don't invent a status. The four are the set; for anything else ("on a call", "in Berlin") write words beside the avatar.
More in specs/avatar.md.
From the package repo: edit this page on GitHub.