10 · Feedback

Spinner

variant canvas/border/soft/grow/svg × size xs–xl × color · elastic · rótulo acessível

Indicador de carregamento curto, com cinco desenhos, cinco tamanhos e as cores do sistema.

Girando nas cores

.heex
<div class="flex flex-wrap items-center gap-2.5"><.spinner :for={c <- ~w(neutral primary secondary info success warning error)} variant="border" size="md" color={c} label={nil} /></div>

variant × size

xssmmdlgxl canvas
border
soft
grow
svg
.heex
<div class="grid grid-cols-[70px_repeat(5,minmax(0,1fr))] items-center gap-x-3 gap-y-2.5">
  <span></span>
  <span :for={s <- ~w(xs sm md lg xl)} class="text-center font-mono text-xs text-muted">{s}</span>
  <%= for v <- ~w(canvas border soft grow svg) do %>
    <span class="font-mono text-xs text-muted">{v}</span>
    <div :for={s <- ~w(xs sm md lg xl)} class="flex min-w-0 justify-center"><.spinner variant={v} size={s} color="primary" label="Carregando" /></div>
  <% end %>
</div>

color

.heex
<div class="flex flex-wrap items-center gap-4"><.spinner :for={c <- ~w(neutral primary secondary info success warning error)} variant="border" size="md" color={c} label={nil} /></div>

Valores da API que completam a paridade

color=white
.heex
<div class="grid grid-cols-3 gap-3.5">
  <div class="flex flex-col items-start gap-1.5"><span class="inline-flex rounded-[10px] bg-inverse p-2.5"><.spinner variant="border" size="md" color="white" label={nil} /></span><span class="font-mono text-[11px] text-muted">color=white</span></div>
</div>

Uso

<.spinner variant="canvas" size="md" color="primary" label="Carregando" />

Regras

  • Sempre com label (lido por leitor de tela).
  • Acima de 1s mostre o que acontece; acima de 4s, progresso.

Referência da API

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

Short loading indicator: five designs, five sizes and the system colours. Styled only with Tailwind utilities (the colour enters as --c, see LedgerUI.Color).

<.spinner color="primary" variant="soft" size="md" label="Saving" />

With a label (default "Loading") it is role="status" and aria-labelled; pass label={nil} for a purely decorative one. white and current (the surrounding text colour) are for spinners inside filled buttons.

<.spinner>

Attr Type Default Values / notes
color :string "neutral" neutral, primary, secondary, info, success, warning, error, white, current
variant :string "canvas" canvas, border, soft, grow, svg
size :string "sm" xs, sm, md, lg, xl
elastic :boolean false An elastic easing instead of the default one.
label :any "Loading" Accessible name; nil for a decorative spinner.
class :any nil

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