Button
color × variant (10 × 9) · size xs–xl · shape · icon, loading, pip, disabled · ButtonGroup
An action button with the same axes as the API: color, variant, size, shape, icon, loading, pip and disabled; button_group joins buttons.
Click, loading, done
<div class="flex flex-wrap items-center gap-2.5"><.button color="mono" class="animate-[mo-bpress_3s_infinite]">Salvar</.button><span class="inline-grid *:[grid-area:1/1]"><span class="animate-[lu-sw-a_4s_ease-in-out_infinite]"><.button color="primary"><.spinner color="white" variant="border" size="xs" label={nil} />Emitindo…</.button></span><span class="opacity-0 animate-[lu-sw-b_4s_ease-in-out_infinite]"><.button color="success"><.icon name="check" />Emitida</.button></span></span><span class="inline-flex rounded-[10px] [--c:var(--color-accent)] animate-[mo-glow_2.4s_ease-in-out_infinite]"><.button color="primary" variant="glow">Assinar plano</.button></span></div>
color × variant
<div style="display:grid;grid-template-columns:80px repeat(9, minmax(0,1fr));gap:10px 12px;align-items:center"><span></span><span class="text-center font-mono text-xs text-muted">neutral</span><span class="text-center font-mono text-xs text-muted">primary</span><span class="text-center font-mono text-xs text-muted">secondary</span><span class="text-center font-mono text-xs text-muted">info</span><span class="text-center font-mono text-xs text-muted">success</span><span class="text-center font-mono text-xs text-muted">warning</span><span class="text-center font-mono text-xs text-muted">error</span><span class="text-center font-mono text-xs text-muted">white</span><span class="text-center font-mono text-xs text-muted">mono</span><span class="font-mono text-xs text-muted">solid</span><div style="display:flex;justify-content:center;min-width:0"><.button size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="primary" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="secondary" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="info" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="success" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="warning" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="error" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="white" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="mono" size="sm">Botão</.button></div><span class="font-mono text-xs text-muted">glow</span><div style="display:flex;justify-content:center;min-width:0"><.button variant="glow" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="primary" variant="glow" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="secondary" variant="glow" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="info" variant="glow" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="success" variant="glow" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="warning" variant="glow" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="error" variant="glow" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="white" variant="glow" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="mono" variant="glow" size="sm">Botão</.button></div><span class="font-mono text-xs text-muted">outline</span><div style="display:flex;justify-content:center;min-width:0"><.button variant="outline" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="primary" variant="outline" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="secondary" variant="outline" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="info" variant="outline" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="success" variant="outline" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="warning" variant="outline" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="error" variant="outline" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="white" variant="outline" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="mono" variant="outline" size="sm">Botão</.button></div><span class="font-mono text-xs text-muted">soft</span><div style="display:flex;justify-content:center;min-width:0"><.button variant="soft" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="primary" variant="soft" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="secondary" variant="soft" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="info" variant="soft" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="success" variant="soft" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="warning" variant="soft" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="error" variant="soft" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="white" variant="soft" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="mono" variant="soft" size="sm">Botão</.button></div><span class="font-mono text-xs text-muted">bordered</span><div style="display:flex;justify-content:center;min-width:0"><.button variant="bordered" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="primary" variant="bordered" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="secondary" variant="bordered" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="info" variant="bordered" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="success" variant="bordered" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="warning" variant="bordered" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="error" variant="bordered" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="white" variant="bordered" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="mono" variant="bordered" size="sm">Botão</.button></div><span class="font-mono text-xs text-muted">flat</span><div style="display:flex;justify-content:center;min-width:0"><.button variant="flat" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="primary" variant="flat" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="secondary" variant="flat" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="info" variant="flat" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="success" variant="flat" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="warning" variant="flat" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="error" variant="flat" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="white" variant="flat" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="mono" variant="flat" size="sm">Botão</.button></div><span class="font-mono text-xs text-muted">glass</span><div style="display:flex;justify-content:center;min-width:0"><.button variant="glass" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="primary" variant="glass" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="secondary" variant="glass" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="info" variant="glass" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="success" variant="glass" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="warning" variant="glass" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="error" variant="glass" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="white" variant="glass" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="mono" variant="glass" size="sm">Botão</.button></div><span class="font-mono text-xs text-muted">ghost</span><div style="display:flex;justify-content:center;min-width:0"><.button variant="ghost" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="primary" variant="ghost" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="secondary" variant="ghost" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="info" variant="ghost" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="success" variant="ghost" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="warning" variant="ghost" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="error" variant="ghost" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="white" variant="ghost" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="mono" variant="ghost" size="sm">Botão</.button></div><span class="font-mono text-xs text-muted">dim</span><div style="display:flex;justify-content:center;min-width:0"><.button variant="dim" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="primary" variant="dim" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="secondary" variant="dim" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="info" variant="dim" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="success" variant="dim" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="warning" variant="dim" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="error" variant="dim" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="white" variant="dim" size="sm">Botão</.button></div><div style="display:flex;justify-content:center;min-width:0"><.button color="mono" variant="dim" size="sm">Botão</.button></div></div>
size
<div class="flex flex-wrap items-center gap-3"><.button size="xs">XS</.button><.button size="sm">SM</.button><.button>MD</.button><.button size="lg">LG</.button><.button size="xl">XL</.button></div>
shape
<div class="flex flex-wrap items-center gap-3"><.button>Rounded</.button><.button shape="pill">Pill</.button><.button icon aria-label="Adicionar"><.icon name="plus" /></.button><.button color="primary" variant="soft" icon aria-label="IA"><.icon name="sparkles" /></.button></div>
states
<div class="flex flex-wrap items-center gap-3"><.button><.icon name="download" />Export report</.button><.button variant="outline">Com ícone à direita<.icon name="arrow-right" /></.button><.button disabled>Disabled</.button><.button loading>Salvando</.button><.button icon variant="outline" pip aria-label="Notificações"><.icon name="bell" /></.button></div>
button_group
<div class="flex flex-wrap items-center gap-3"><.button_group><.button variant="outline" size="sm">Day</.button><.button variant="outline" size="sm">Week</.button><.button variant="soft" size="sm">Month</.button></.button_group><.button_group shape="pill"><.button variant="outline" size="sm"><.icon name="chevron-left" />Anterior</.button><.button variant="outline" size="sm">Próximo<.icon name="chevron-right" /></.button></.button_group><.button_group><.button>Salvar</.button><.button icon aria-label="Mais opções"><.icon name="chevron-down" /></.button></.button_group></div>
API values that complete the parity
<div class="grid grid-cols-4 gap-3.5"><div class="flex flex-col items-start gap-1.5"><span class="text-violet"><.button color="current" variant="ghost">Herda a cor</.button></span><span class="font-mono text-[11px] text-muted">color=current</span></div></div>
Icon-only (canvas): pressing and toggling
<div class="flex flex-wrap items-center gap-2.5"><.button canvas appearance="default" icon="download" aria-label="Baixar" class="animate-[mo-bpress_3s_infinite]" /><span class="inline-grid *:[grid-area:1/1]"><span class="animate-[lu-sw-a_4s_ease-in-out_infinite]"><.button canvas appearance="default" icon="star" aria-label="Favoritar" /></span><span class="text-warn opacity-0 animate-[lu-sw-b_4s_ease-in-out_infinite]"><.button canvas appearance="default" icon="star" aria-label="Favorito" /></span></span><.button canvas appearance="default" icon="bell" aria-label="Notificações" class="origin-top animate-[mo-wiggle_5s_ease-in-out_infinite]" /></div>
Icon-only (canvas): appearance primary · default · soft · ghost · danger-soft · accent
<div class="flex flex-wrap items-center gap-2.5"><.button canvas appearance="primary" icon="plus" aria-label="Adicionar" /><.button canvas appearance="default" icon="filter" aria-label="Filtrar" /><.button canvas appearance="soft" icon="more-h" aria-label="Mais" /><.button canvas appearance="ghost" icon="x" aria-label="Fechar" /><.button canvas appearance="danger-soft" icon="trash" aria-label="Excluir" /><.button canvas appearance="accent" icon="sparkles" aria-label="IA" /></div>
Icon-only (canvas): size sm · md · lg
<div class="flex flex-wrap items-center gap-2.5"><.button canvas appearance="default" size="sm" icon="settings" aria-label="Config" /><.button canvas appearance="default" icon="settings" aria-label="Config" /><.button canvas appearance="default" size="lg" icon="settings" aria-label="Config" /></div>
Top bar: appearance topbar with pip, appearance go and insight_button
<div class="flex flex-wrap items-center gap-2.5"><.insight_button count={3}>New AI insights</.insight_button><.button canvas appearance="topbar" icon="bell" aria-label="Notificações" pip /><.button canvas appearance="topbar" icon="moon" aria-label="Tema escuro" /><.button canvas appearance="go" icon="arrow-right" aria-label="Abrir" /></div>
Kit icon-only: color, variant, size and square shape
<div class="flex flex-wrap items-center gap-2.5"><.button icon="x" color="error" variant="outline" size="xs" shape="square" aria-label="Remover" /><.button icon="plus" color="primary" variant="solid" aria-label="Adicionar" /><.button icon="settings" color="neutral" variant="soft" size="lg" aria-label="Config" /><.button icon="star" color="warning" variant="bordered" size="xl" aria-label="Favoritar" /></div>
Usage
<.button color="neutral" variant="solid" size="md" shape="rounded">Export report</.button> <.button color="primary" variant="soft" icon><.icon name="huge-add-01" /></.button> <.button loading>Salvando</.button> <.button pip variant="ghost" icon>…</.button> <.button_group shape="pill">…</.button_group>
Rules
- Default:
color="neutral" variant="solid"= the example's black button (shadow-btnshadow). glowadds a colored shadow;glassis translucent with blur, to go over images/gradients;dimis the muted solid (a strong secondary action).shape="square"+icon= an icon-only button;pillexists only through the API (the system default isrounded).loadingswaps the content for a spinner keeping the width;pipputs the notification dot in the corner.
API reference
Todos os function components, atributos, valores e slots que este componente cobre.
Buttons, styled only with Tailwind utilities: button/1 (which also covers the icon-only, top bar
(appearance="topbar") and round "go" (appearance="go") buttons), button_group/1 and
insight_button/1.
<.button>Export report</.button>
<.button color="primary" variant="soft" size="sm">Save</.button>
<.button color="error" variant="outline" shape="pill">Delete</.button>
<.button color="primary" variant="soft" icon="huge-sparkles" aria-label="IA" />
<.button navigate={~p"/orders"} variant="ghost">Orders</.button>
<.button color="primary" loading={@saving}>Saving</.button>
<.button canvas size="sm" appearance="primary">Confirm</.button>
<.button variant="outline" icon="huge-bell" pip aria-label="Notifications" />
<.button_group shape="pill">
<.button variant="outline" size="sm">Day</.button>
<.button variant="outline" size="sm">Week</.button>
</.button_group>
<.button canvas appearance="topbar" icon="notification-03" pip aria-label="Notifications" />
<.button canvas appearance="go" icon="arrow-right" aria-label="Send" />
The colour enters as four local variables (--c, --c-on, --c-soft, --c-ink, see
LedgerUI.Color) and each variant only reads those: 10 colours x 9 variants without a
combinatorics of classes. The default color="neutral" variant="solid" is the black button of the
system. color="current" follows the text colour of the parent.
With href, navigate or patch a link is rendered that looks the same. Without content and with
icon, the button is icon-only (shape="square"); icon also accepts true (square button whose
content is the slot, e.g. an inline SVG).
loading blocks the button (no double submit) with disabled (links: aria-disabled) plus
aria-busy, hides the label keeping the width and shows a spinner on top. It is not inert, so the
spinner's role="status" is announced. pip puts the notification dot on the corner.
To change a measure pick the matching attr (size, shape): two utilities of one property in a
class list are resolved by the stylesheet, never by their order, so class is for layout
(w-full, ml-auto), not for overriding the component's own look.
<.button>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
color |
:string |
"neutral" |
current, dark, error, info, light, lime, mono, neutral, primary, secondary, success, warning, white - current takes the parent's text colour. |
variant |
:string |
"solid" |
bordered, dim, flat, ghost, glass, glow, outline, soft, solid |
size |
:string |
"md" |
lg, md, sm, xl, xs |
shape |
:string |
nil |
nil, rounded, pill, square - square is the icon-only button; without shape it is chosen from icon and the content. |
icon |
:any |
nil |
An icon name ("huge-plus", "plus"): that icon before the label; without content the button is icon-only. true: a square button holding only the slot (pass aria-label). |
trailing_icon |
:string |
nil |
An icon name after the label. |
canvas |
:boolean |
false |
The compact toolbar button of the canvas: size (sm/lg) and appearance apply, color, variant and shape do not. |
appearance |
:string |
"default" |
default, primary, accent, soft, ghost, danger-soft, topbar, go - Look of the canvas button: default (panel with a border), primary (the inverse, black button), accent, soft, ghost (no box), danger-soft, topbar (the 40x40 top bar button) or go (the 30px round accent arrow). topbar and go have a fixed size: size is ignored. |
part |
:string |
"button" |
The data-part of the element ("icon-button" for the canvas icon buttons). |
type |
:string |
"button" |
|
disabled |
:boolean |
false |
|
loading |
:boolean |
false |
Disables the button (no clicks), marks it aria-busy, shows a spinner (announced: not inert). |
pip |
:boolean |
false |
The notification dot on the corner. |
loading_label |
:string |
"Loading" |
Read by screen readers for the spinner. |
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element, including href, navigate, patch, method, download, target, rel, replace, form, name, value.
Slots:
<:inner_block>
<.button_group>
Joins buttons side by side into one segmented control (corners only at the ends).
<.button_group>
<.button variant="outline" size="sm">Day</.button>
<.button variant="soft" size="sm">Month</.button>
</.button_group>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
shape |
:string |
"rounded" |
rounded, pill |
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:inner_block>(required)
<.insight_button>
The top bar pill with a count badge (New AI insights).
With href, navigate or patch it renders a link (<.link>, no type) with the same look.
icon replaces the count inside the same square box; if icon and count are both given, icon
wins.
<.insight_button count={3}>New AI insights</.insight_button>
<.insight_button navigate={~p"/insights"} icon="huge-sparkles">AI suggestions</.insight_button>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
count |
:any |
nil |
The number in the square badge. |
icon |
:string |
nil |
Icon name shown in the badge box instead of the count. Wins over count. |
type |
:string |
"button" |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element, including href, navigate, patch, method, download, target, rel, replace, form, name, value.
Slots:
<:inner_block>(required)