Buttons.
A port of the Pines button. Pure Tailwind — no
Alpine required — except for the optional loading state, which only toggles classes.
<.button>Save</.button>
<.button variant="destructive" phx-click="delete">Delete</.button>
<.button variant="outline" size="sm">Cancel</.button>
Summary
Forms
Renders a button.
Forms
Renders a button.
Examples
<.button>Save changes</.button>
<.button variant="destructive" phx-click="delete" phx-value-id={@item.id}>
Delete
</.button>
<.button loading={@saving} disabled={@saving}>
<:icon><Heroicons.check class="h-4 w-4" /></:icon>
Save
</.button>Accessibility
While loading is true the button is marked aria-busy and the spinner is hidden from
assistive technology, so a screen reader announces the label rather than the decoration.
Attributes
variant(:string) - Visual style. One of primary, secondary, destructive, outline, ghost, link. Defaults to"primary". Must be one of"primary","secondary","destructive","outline","ghost", or"link".size(:string) - Control size.iconrenders a square button sized for a single glyph. Defaults to"md". Must be one of"sm","md","lg", or"icon".type(:string) - The HTML button type. Defaults tobuttonso it never submits a form by accident. Defaults to"button". Must be one of"button","submit", or"reset".disabled(:boolean) - Defaults tofalse.loading(:boolean) - Shows a spinner and disables interaction. Defaults tofalse.class(:string) - Extra classes. These override the defaults. Defaults tonil.- Global attributes are accepted. Any other attribute, including
phx-*and Alpinex-*.
Slots
inner_block(required)icon- Rendered before the label.