06 · Display

Avatar

size 3xs–2xl · shape (12) · color (8) × variant solid/soft/bordered/skeleton · kind · status

Represents a person or account by photo or initials, with an optional status.

Speaking and live status

AN CA FP RS
.heex
<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

AN 3xs
AN 2xs
AN xs
AN sm
AN md
AN lg
AN xl
AN 2xl
.heex
<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)

AN circle
AN square
AN rounded
AN squircle
AN reuleaux-triangle
AN diamond
AN hexagon
AN hexagon-2
AN octagon
AN star
AN star-2
AN heart
.heex
<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

solidsoftborderedskeletonauto
BP
BP
BP
BP
neutral
BP
BP
BP
BP
primary
BP
BP
BP
BP
secondary
BP
BP
BP
BP
info
BP
BP
BP
BP
success
BP
BP
BP
BP
warning
BP
BP
BP
BP
error
BP
BP
BP
BP
.heex
<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

company
customer
supplier
assistant
invite
AN on
AN away
AN busy
AN off
.heex
<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>

API values that complete the parity

AN size=xs-plus
AN size=sm-plus
AN size=24
AN size=26
AN size=30
AN size=32
AN size=40
AN size=44
AN size=48
AN size=64
AN status=online
AN status=offline
AN status=false
AN status_position=bottom-right
AN status_position=bottom-left
AN status_position=top-right
AN status_position=top-left
AN ring=true
AN ring=1
AN ring=false
AN ring_color=white
AN gradient=amber-orange
AN gradient=fuchsia-pink
AN gradient=green-fuchsia
AN gradient=pink-rose
AN gradient=purple-indigo
AN gradient=purple-orange
AN gradient=sky-blue
AN CA FP overlap=3
AN CA FP overlap=7
.heex
<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>

Usage

<.avatar name="Ikram Sakib" src={@user.photo} status="online" size="md" />

Rules

  • Initials: the tone is chosen by the hash of the name, always the same 5 tones.
  • mono variant (initials in Geist Mono with a ring) for dense table rows.
  • Accounts/companies use the square (30% radius); people, the circle.

API reference

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)