Avatar
size 3xs–2xl · shape (12) · color (8) × variant solid/soft/bordered/skeleton · kind · status
Representa uma pessoa ou conta por foto ou iniciais, com status opcional.
Falando e status ao vivo
<div class="flex flex-wrap items-center gap-2.5"><.avatar initials="AN" color="primary" variant="soft" size="40" speak /><.avatar initials="CA" color="secondary" variant="soft" size="40" status="online" ping /><.avatar initials="FP" color="warning" variant="soft" size="40" status="away" ping /><.avatar initials="RS" color="error" variant="soft" size="40" status="busy" ping /></div>
size
<div class="flex flex-wrap items-start gap-2.5"><div :for={s <- ~w(3xs 2xs xs sm md lg xl 2xl)} class="flex flex-col gap-1"><.avatar initials="AN" color="primary" variant="soft" size={s} /><span class="font-mono text-xs text-muted">{s}</span></div></div>
shape (12)
<div class="flex flex-wrap items-start gap-2.5"><div :for={s <- ~w(circle square rounded squircle reuleaux-triangle diamond hexagon hexagon-2 octagon star star-2 heart)} class="flex flex-col gap-1"><.avatar initials="AN" color="primary" shape={s} size="44" /><span class="font-mono text-xs text-muted">{s}</span></div></div>
color × variant
<div class="grid grid-cols-[90px_repeat(4,minmax(0,1fr))] items-center gap-x-3 gap-y-2.5"><span></span><span :for={v <- ~w(solid soft bordered skeleton)} class="text-center font-mono text-xs text-muted">{v}</span><%= for c <- ~w(auto neutral primary secondary info success warning error) do %><span class="font-mono text-xs text-muted">{c}</span><div :for={v <- ~w(solid soft bordered skeleton)} class="flex min-w-0 justify-center"><.avatar initials="BP" color={if c == "auto", do: "primary", else: c} variant={v} size="40" /></div><% end %></div>
kind · status
<div class="flex flex-wrap items-start gap-2.5"><div :for={k <- ~w(company customer supplier assistant invite)} class="flex flex-col gap-1"><.avatar kind={k} size="40" /><span class="font-mono text-xs text-muted">{k}</span></div><div :for={{s, l} <- [{"online", "on"}, {"away", "away"}, {"busy", "busy"}, {"offline", "off"}]} class="flex flex-col gap-1"><.avatar initials="AN" color="primary" variant="soft" size="40" status={s} ping /><span class="font-mono text-xs text-muted">{l}</span></div></div>
Valores da API que completam a paridade
<div class="flex flex-col gap-4"><div class="grid grid-cols-10 gap-3.5"><div :for={s <- ~w(xs-plus sm-plus 24 26 30 32 40 44 48 64)} class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size={s} /><span class="font-mono text-[11px] text-muted">size={s}</span></div></div><div class="grid grid-cols-7 gap-3.5"><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" status="online" ping /><span class="font-mono text-[11px] text-muted">status=online</span></div><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" status="offline" ping /><span class="font-mono text-[11px] text-muted">status=offline</span></div><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" status={false} /><span class="font-mono text-[11px] text-muted">status=false</span></div><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" status="online" status_position="bottom-right" ping /><span class="font-mono text-[11px] text-muted">status_position=bottom-right</span></div><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" status="online" status_position="bottom-left" ping /><span class="font-mono text-[11px] text-muted">status_position=bottom-left</span></div><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" status="online" status_position="top-right" ping /><span class="font-mono text-[11px] text-muted">status_position=top-right</span></div><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" status="online" status_position="top-left" ping /><span class="font-mono text-[11px] text-muted">status_position=top-left</span></div></div><div class="grid grid-cols-11 gap-3.5"><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" ring /><span class="font-mono text-[11px] text-muted">ring=true</span></div><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" ring={1} /><span class="font-mono text-[11px] text-muted">ring=1</span></div><div class="flex flex-col items-start gap-1.5"><.avatar initials="AN" color="primary" variant="soft" size="40" ring={false} /><span class="font-mono text-[11px] text-muted">ring=false</span></div><div class="flex flex-col items-start gap-1.5"><span style="background:var(--lu-inverse);padding:6px;border-radius:12px"><.avatar initials="AN" color="primary" variant="soft" size="40" ring ring_color="white" /></span><span class="font-mono text-[11px] text-muted">ring_color=white</span></div><div :for={g <- ~w(amber-orange fuchsia-pink green-fuchsia pink-rose purple-indigo purple-orange sky-blue)} class="flex flex-col items-start gap-1.5"><.avatar initials="AN" size="40" gradient={g} /><span class="font-mono text-[11px] text-muted">gradient={g}</span></div></div><div class="grid grid-cols-4 gap-3.5"><div :for={o <- ~w(3 7)} class="flex flex-col items-start gap-1.5"><.avatar_group overlap={o} style="display:inline-flex"><.avatar :for={i <- ~w(AN CA FP)} initials={i} color="primary" variant="soft" size="32" /></.avatar_group><span class="font-mono text-[11px] text-muted">overlap={o}</span></div></div></div>
Uso
<.avatar name="Ikram Sakib" src={@user.photo} status="online" size="md" />
Regras
- Iniciais: tom escolhido pelo hash do nome, sempre os mesmos 5 tons.
- Variante
mono(iniciais em Geist Mono com anel) para linhas de tabela densas. - Contas/empresas usam o quadrado (raio 30%); pessoas, círculo.
Referência da API
Todos os function components, atributos, valores e slots que este componente cobre.
Avatars: an image or initials in a circle, a square, a squircle or any mask shape, with a status dot, a gradient ring, and stacked in groups.
<.avatar name="Ana Souza" color="auto" size="md" status="online" />
<.avatar initials="jd" color="info" variant="soft" />
<.avatar src="/images/jane.jpg" alt="Jane" gradient="sky-blue" size="lg" />
<.avatar kind="assistant" size="md" />
<.avatar_group more={3} size="sm">
<.avatar :for={user <- @users} name={user.name} color="auto" size="sm" ring />
</.avatar_group>
size takes the names (3xs 16px, 2xs 20px, xs 24px, xs-plus 26px, sm 30px,
md 36px, lg 44px, xl 56px, 2xl 72px, sm-plus 32px) or any number of pixels
("40"). The legacy palette of the canvas is available with color t1..t5
(pastel tones), and color="none" leaves only the base face. variant="mono" is the dense
table avatar: initials in the mono font on a ring. Styled only with Tailwind utilities.
<.avatar>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
src |
:string |
nil |
|
alt |
:string |
nil |
The picture's text; the name when not given. |
initials |
:string |
nil |
Shown (upper-cased) when there is no src. |
name |
:string |
nil |
Gives the initials (first and last word) and color="auto". |
icon |
:string |
nil |
An icon drawn on the sunken face. |
kind |
:string |
nil |
nil, company, customer, supplier, assistant, invite |
size |
:string |
"sm" |
A size name or a number of pixels. |
shape |
:string |
"circle" |
circle, square, rounded, squircle, reuleaux-triangle, diamond, hexagon, hexagon-2, octagon, star, star-2, heart |
tint |
:string |
nil |
CSS color for the initials' background (white text). |
background |
:string |
nil |
Any CSS background for the face (white text). |
color |
:string |
"neutral" |
auto, neutral, primary, secondary, info, success, warning, error, t1, t2, t3, t4, t5, none |
variant |
:string |
"solid" |
solid, soft, bordered, skeleton, mono |
status |
:any |
nil |
Presence (online, away, busy, offline) or a tone; nil/false shows no dot. |
status_position |
:string |
nil |
nil, bottom-left, bottom-right, top-left, top-right |
ping |
:boolean |
false |
Animates the status dot. |
ring |
:any |
false |
true, 1, 2 or 4. |
speak |
:boolean |
false |
Speaking: a 2px page-colour gap, a 4px accent ring that pulses (mo-speak). |
ring_color |
:string |
nil |
nil, white, panel, neutral, primary, secondary, info, success, warning, error |
face_class |
:any |
nil |
|
gradient |
:string |
nil |
nil, sky-blue, amber-orange, pink-rose, purple-orange, green-fuchsia, purple-indigo, fuchsia-pink |
style |
:string |
nil |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:inner_block>- Replaces the initials (an icon, a counter).
<.avatar_group>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
pulse |
:boolean |
false |
|
overlap |
:string |
"2" |
2, 3, 7, auto |
more |
:integer |
nil |
Draws a "+N" avatar at the end. |
hidden |
:list |
nil |
The people that did not fit (maps with :name, optional :src). Needs id. |
id |
:string |
nil |
|
size |
:string |
"xs" |
|
spread |
:boolean |
false |
|
ring_color |
:string |
"white" |
white, panel |
label |
:string |
nil |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:inner_block>(required)