10 · Feedback

Skeleton

animation wave/pulse/none × shape rounded/pill/circle/square/lg · skeleton_group

A loading placeholder that mirrors the final layout.

Loading and the content arriving

Mercadinho Bom Preço12 pedidos este mês · R$ 14.280
.heex
<div class="inline-grid w-[360px] [&>*]:[grid-area:1/1]">
  <div class="flex flex-col gap-2 animate-[lu-sw-a_4s_ease-in-out_infinite]"><.skeleton tag="span" animation={nil} class="h-3.5 w-[70%]" /><.skeleton tag="span" animation={nil} class="h-3.5 w-[90%]" /><.skeleton tag="span" animation={nil} class="h-3.5 w-1/2" /></div>
  <div class="flex flex-col gap-1 opacity-0 animate-[lu-sw-b_4s_ease-in-out_infinite]"><b>Mercadinho Bom Preço</b><span class="text-[13px] leading-[18px] text-muted">12 pedidos este mês · R$ 14.280</span></div>
</div>

animation

wave
pulse
none
.heex
<div class="grid grid-cols-3 gap-4">
  <div :for={a <- ~w(wave pulse none)} class="flex flex-col gap-2">
    <span class="font-mono text-xs text-muted">{a}</span>
    <.skeleton animation={a} class="w-4/5" />
    <.skeleton animation={a} class="w-[55%]" />
  </div>
</div>

shape

.heex
<div class="flex flex-wrap items-center gap-3.5">
  <.skeleton shape="rounded" class="h-3.5 w-[120px]" />
  <.skeleton shape="pill" class="h-3.5 w-[120px]" />
  <.skeleton shape="circle" class="size-10" />
  <.skeleton shape="square" class="size-10" />
  <.skeleton shape="lg" class="h-16 w-40" />
</div>

skeleton_group (KPI card)

.heex
<.card aria-busy="true" aria-label="Carregando" class="max-w-[300px]">
  <:title><.skeleton class="w-[90px]" /></:title>
  <div class="flex flex-col gap-3">
    <.skeleton class="h-[34px] w-[60%] rounded-lg" />
    <.skeleton class="w-2/5" />
  </div>
</.card>

API values that complete the parity

variant=canvas
variant=lineone
.heex
<div class="grid grid-cols-3 gap-3.5">
  <div :for={v <- ~w(canvas lineone)} class="flex flex-col items-start gap-1.5">
    <div class="flex w-full flex-col gap-1.5"><.skeleton variant={v} tag="span" animation={nil} class="h-3 w-4/5" /><.skeleton variant={v} tag="span" animation={nil} class="h-3 w-3/5" /></div>
    <span class="font-mono text-[11px] text-muted">variant={v}</span>
  </div>
</div>

Usage

<.skeleton class="h-3 w-40" animation="wave" />
<.skeleton_group label="Carregando contas">…</.skeleton_group>

Rules

  • Mirror the real shape (KPI, table row) so the layout does not jump.
  • skeleton_group groups with an accessible label.

API reference

Todos os function components, atributos, valores e slots que este componente cobre.

Loading placeholder that mirrors the final layout. Styled only with Tailwind utilities; the size comes from class (a block is 12px high until a h-* class says otherwise).

<.skeleton class="h-3 w-40" animation="wave" />
<.skeleton shape="circle" class="size-10" />

<.skeleton_group label="Loading orders">
  <.skeleton class="w-3/5" />
</.skeleton_group>

skeleton_group with loop and a :loaded slot plays the canvas loop: the placeholder, then the content that arrives, in turn (CSS only).

animation={nil} (or "none") draws a still block; tag="span" draws a span (inside a flex column). shape is the corner: the base block has the small radius, so "rounded" (or nil) keeps it.

<.skeleton>

Attr Type Default Values / notes
animation :string "wave" nil, wave, pulse, none
variant :string "canvas" canvas, lineone
shape :string nil nil, rounded, pill, circle, square, lg
tag :string "div" div, span - The element drawn.
class :any nil

Any other HTML/phx attribute goes to the root element.

<.skeleton_group>

Attr Type Default Values / notes
label :string "Loading…" Read by screen readers; not drawn.
loop :boolean false The canvas loop (lu-sw-a/lu-sw-b): the placeholder, then the :loaded content, forever (demos).
class :any nil

Any other HTML/phx attribute goes to the root element.

Slots:

  • <:inner_block> (required)
  • <:loaded> - With loop: the content that replaces the placeholder.