Button component with full variant, size, loading, and icon support.
Variants
primary— filled purple, main CTAsecondary— outlined, secondary actionsghost— no border, subtle actionsdanger— red tint, destructive actionsoutline— neutral outlinelink— looks like a hyperlink
Sizes
xs,sm,md(default),lg,xl
Examples
<.button>Deploy</.button>
<.button variant="secondary" size="sm">Cancel</.button>
<.button variant="danger" phx-click="delete" phx-value-id={@item.id}>
Delete project
</.button>
<.button loading={@saving}>
<.button_icon><.spinner /></.button_icon>
Saving…
</.button>
<.button variant="primary" size="lg" disabled>
Locked
</.button>
Summary
Functions
Renders a button with variants, sizes, and loading state support.
Icon wrapper inside a button — handles sizing consistently.
Functions
Renders a button with variants, sizes, and loading state support.
Attributes
variant(:string) - Defaults to"primary". Must be one of"primary","secondary","ghost","danger","outline", or"link".size(:string) - Defaults to"md". Must be one of"xs","sm","md","lg", or"xl".type(:string) - Defaults to"button". Must be one of"button","submit", or"reset".loading(:boolean) - Defaults tofalse.disabled(:boolean) - Defaults tofalse.class(:string) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["phx-click", "phx-submit", "phx-value", "phx-target", "form"].
Slots
inner_block(required)
Icon wrapper inside a button — handles sizing consistently.
Attributes
class(:string) - Defaults tonil.
Slots
inner_block(required)