Buttons

Trigger actions — submit a form, open a modal, navigate. Eight color variants, four sizes, disabled state, and first-class HTMX wiring (GET/POST/DELETE, confirm, loading indicator).

Usage Example
@button.Button(button.Config{Variant: button.Primary, Type: "button"}) { Primary }
@button.Button(button.Config{Variant: button.Secondary, Type: "button"}) { Secondary }
@button.Button(button.Config{Variant: button.Danger, Type: "button"}) { Danger }
@button.Button(button.Config{Variant: button.Success, Type: "button"}) { Success }

Sizes

Four sizes via Size: SizeSmall, SizeMedium, SizeLarge, SizeXLarge.

Sizes
@button.Button(button.Config{
    Variant: button.Primary,
    Size:    button.SizeMedium,
    Type:    "button",
}) { Medium }

Disabled

Disabled: true blocks interaction and dims the button.

Disabled
@button.Button(button.Config{Variant: button.Primary, Type: "button", Disabled: true}) { Primary }

HTMX Interactions

Attach an HTMX config to fire a request on click. Supports Get/Post/Delete, a Confirm prompt, a loading Indicator, and LoadingText.

Waiting for server response...
Waiting for server response...
Waiting for server response...
HTMX Interactions
@button.Button(button.Config{
    Variant: button.Primary, Type: "button", RootClass: "w-full sm:w-44 justify-center",
    HTMX: &button.HTMXConfig{Post: "/api/hello", Target: "#htmx-result-post", Swap: "innerHTML"},
}) { Send POST }

@button.Button(button.Config{
    Variant: button.Info, Type: "button", RootClass: "w-full sm:w-44 justify-center",
    HTMX: &button.HTMXConfig{Get: "/api/hello", Target: "#htmx-result-get", Swap: "innerHTML"},
}) { Send GET }

@button.Button(button.Config{
    Variant: button.Danger, Type: "button", RootClass: "w-full sm:w-44 justify-center",
    HTMX: &button.HTMXConfig{Delete: "/api/hello", Confirm: "Are you sure?", Target: "#htmx-result-delete", Swap: "innerHTML"},
}) { Delete }

API Reference

PropTypeDefaultDescription
VariantVariantPrimaryColor: "primary", "secondary", "alternate", "inverse", "info", "danger", "warning", "success".
SizeSizeSizeMediumSize: "sm", "md", "lg", "xl".
Typestring"button"Native button type: "button", "submit", "reset".
DisabledboolfalseDisable interaction.
HTMX*HTMXConfignilHTMX wiring (Get/Post/Put/Delete, Target, Swap, Trigger, Confirm, Indicator).
Alpine*AlpineConfignilAlpine.js directives for client-side behavior.
LoadingTextstring""Text shown while an HTMX request is in flight.
IDstring""Optional element id.
RootClassstring""Extra classes on the button.