06 · Display

Badge

color (10) × variant solid/glow/soft/outline/flat · size xs–lg · shape rounded/pill/square

A short status or category label. 6px corners, never a pill.

Counter arriving and live

3Ao vivoPagoNovo
.heex
<div class="flex flex-wrap items-center gap-2.5"><.badge color="error" variant="solid" shape="pill" class="animate-[mo-pulse_2s_ease-in-out_infinite]">3</.badge><.badge canvas color="primary" class="uppercase tracking-[.06em] text-[11px] font-semibold" dot="live">Ao vivo</.badge><.badge color="success" variant="soft"><span class="animate-[mo-stg_6s_cubic-bezier(.2,.8,.2,1)_infinite]">Pago</span></.badge><.badge color="primary" variant="glow" class="animate-[mo-glow_2.4s_ease-in-out_infinite]">Novo</.badge></div>

color (10) × variant

solidglowsoftoutlineflatneutral
Neutral
Neutral
Neutral
Neutral
Neutral
primary
Primary
Primary
Primary
Primary
Primary
secondary
Secondary
Secondary
Secondary
Secondary
Secondary
info
Info
Info
Info
Info
Info
success
Success
Success
Success
Success
Success
warning
Warning
Warning
Warning
Warning
Warning
error
Error
Error
Error
Error
Error
dark
Dark
Dark
Dark
Dark
Dark
light
Light
Light
Light
Light
Light
white
White
White
White
White
White
.heex
<div style="display:grid;grid-template-columns:80px repeat(5, minmax(0,1fr));gap:10px 12px;align-items:center"><span></span><span :for={v <- ~w(solid glow soft outline flat)} class="text-center font-mono text-xs text-muted">{v}</span><%= for c <- ~w(neutral primary secondary info success warning error dark light white) do %><span class="font-mono text-xs text-muted">{c}</span><div :for={v <- ~w(solid glow soft outline flat)} style="display:flex;justify-content:center;min-width:0"><.badge color={c} variant={v}>{String.capitalize(c)}</.badge></div><% end %></div>

size · shape

xssmpadrãomdlgroundedpillsquare
.heex
<div class="flex flex-wrap items-center gap-2.5"><.badge color="primary" size="xs">xs</.badge><.badge color="primary" size="sm">sm</.badge><.badge color="primary">padrão</.badge><.badge color="primary" size="md">md</.badge><.badge color="primary" size="lg">lg</.badge><.badge variant="outline" shape="rounded">rounded</.badge><.badge variant="outline" shape="pill">pill</.badge><.badge variant="outline" shape="square">square</.badge></div>

Soft

NeutroMarca+8.8%−$3,400 MRRPendenteInfo+$4,200 potential3 newPro
.heex
<div class="flex flex-wrap items-center gap-2.5"><.badge canvas>Neutro</.badge><.badge canvas color="primary">Marca</.badge><.badge canvas color="success">+8.8%</.badge><.badge canvas color="error">−$3,400 MRR</.badge><.badge canvas color="warning">Pendente</.badge><.badge canvas color="info">Info</.badge><.badge canvas color="lime">+$4,200 potential</.badge><.badge canvas color="lime"><.icon name="sparkles" />3 new</.badge><.badge canvas variant="solid">Pro</.badge></div>

Outline (tables)

Needs approvalOpenSolvedMediumCriticalLow
.heex
<div class="flex flex-wrap items-center gap-2.5"><.badge canvas variant="outline" color="warning">Needs approval</.badge><.badge canvas variant="outline">Open</.badge><.badge canvas variant="outline" color="success">Solved</.badge><.badge canvas variant="outline" color="primary">Medium</.badge><.badge canvas variant="outline" color="error" dot>Critical</.badge><.badge canvas variant="outline">Low</.badge></div>

Special

Live2388.8%0.4 ptsBetaGrande
.heex
<div class="flex flex-wrap items-center gap-2.5"><.badge canvas color="primary" class="uppercase tracking-[.06em] text-[11px] font-semibold" dot="live">Live</.badge><.count>23</.count><.count tone="warning">8</.count><.delta trend="up">8.8%</.delta><.delta trend="down">0.4 pts</.delta><.badge canvas color="primary" size="sm">Beta</.badge><.badge canvas size="lg">Grande</.badge></div>

Usage

<.badge tone="neg">−$3,400 MRR</.badge>
<.badge tone="acc" dot live>LIVE</.badge>

Rules

  • Tone has meaning: pos/neg for values, warn for pending, lime for opportunity, acc for brand/AI.
  • Outline (outline) for status in dense tables, as in the cases example.
  • lu-count is the red navigation counter (23).

API reference

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

Badges: color x variant x size x shape, with a dot, an icon or a remove button. Styled only with Tailwind utilities (the colour enters as --c/--c-on/--c-soft/--c-ink, see LedgerUI.Color).

<.badge>Default</.badge>
<.badge color="success" shape="pill">Paid</.badge>
<.badge color="primary" variant="outline" icon="huge-sparkles">3 new</.badge>
<.badge color="primary" variant="soft" dot>Online</.badge>
<.badge on_remove={JS.hide()}>Filter</.badge>

With canvas the badge is the compact canvas badge (tinted by color: primary, success, error, warning, info, lime; variant solid/outline; size sm/lg), which is what tables and KPI rows use.

<.badge>

Attr Type Default Values / notes
color :string "neutral" current, dark, error, info, light, lime, mono, neutral, primary, secondary, success, warning, white
variant :string "soft" bordered, flat, glow, outline, soft, solid
size :string "md" lg, md, sm, xl, xs
shape :string "rounded" pill, rounded, square
icon :string nil An icon name before the content.
dot :any false A dot before the content; "live" pulses.
canvas :boolean false The compact canvas badge.
on_remove :any nil An event name or a JS command: adds a remove button after the content.
id :string nil
target :any nil The phx-target of on_remove when it is an event.
remove_label :string "Remove"
class :any nil

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

Slots:

  • <:inner_block> (required)

<.count>

The little counter box (18px, rounded 5px) for unread items and pending work.

<.count>23</.count>
<.count tone="warning">8</.count>
Attr Type Default Values / notes
tone :string "error" error, info, primary, success, warning
class :any nil

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

Slots:

  • <:inner_block> (required)

<.delta>

A variation with its arrow: up or down, green or red by meaning.

<.delta trend="up">8.8%</.delta>
<.delta trend="up" tone="error">0.4 pts</.delta>
Attr Type Default Values / notes
trend :string "up" up, down
tone :string nil nil, error, neutral, success - The colour: success (green), error (red) or neutral. Defaults to green for up and red for down.
class :any nil

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

Slots:

  • <:inner_block> (required)