Avatar
A round image of a person or thing, with initials when there is no image.
Display
Added in v0.41.0
Updated
Image and initials
<div class="flex items-center gap-4">
{ui avatar,
src: p('favicon')->file('favicon-96x96.png')->url(),
alt: 'Phlat logo',
/}
{ui avatar, initials: 'AL' /}
</div>
src is a URL, so a page's file is p('page')->file('photo.jpg')->url(). The image keeps a square ratio and crops to fill, so any photo fits the circle. Without src the initials show on a muted fill, upper-cased. Set alt when the avatar stands alone, and leave it empty when the person's name is written beside it.
Sizes
SM
MD
LG
<div class="flex items-center gap-4">
{ui avatar, initials: 'SM', class: 'text-sm' /}
{ui avatar, initials: 'MD' /}
{ui avatar, initials: 'LG', class: 'text-2xl' /}
</div>
The avatar is two and a half times the text size, so a text-* class on it resizes it, with any responsive prefix. The initials scale with it.
Beside a name
AL
Ada Lovelace
Editor
<div class="flex items-center gap-3">
{ui avatar, initials: 'AL' /}
<div>
<p class="font-medium">Ada Lovelace</p>
<p class="text-muted">Editor</p>
</div>
</div>