{#- chirp-ui: Button component. Use chirpui-btn with variants. Supports loading state for htmx. -#} {% from "chirpui/spinner.html" import spinner %} {% def btn(label, variant="", size=none, loading=false, type="submit", href=none, icon=none, cls="", attrs="", attrs_map=none, hx_get=none, hx_post=none, hx_put=none, hx_patch=none, hx_delete=none, hx_target=none, hx_swap=none, hx_trigger=none, hx_include=none, hx_select=none, hx_ext=none, hx_vals=none, disabled=false, data_action=none, aria_label=none) %} {% set _variant = variant | validate_variant_block("btn", "") %} {% set _bar_size = consume("_bar_density", "") %} {% set _busy = consume("_suspense_busy", "") %} {% set _size = (size or _bar_size or "") | validate_size("btn", "") %} {% set _disabled = disabled or (_busy == "true") %} {% set variant_class = " chirpui-btn--" ~ _variant if _variant else "" %} {% set size_class = " chirpui-btn--" ~ _size if _size else "" %} {% set loading_class = " chirpui-btn--loading" if loading else "" %} {% set base_class = "chirpui-btn" ~ variant_class ~ size_class ~ loading_class %} {% if cls %} {% set base_class = base_class ~ " " ~ cls %} {% end %} {% set _btn_has_hx = hx_get or hx_post or hx_put or hx_patch or hx_delete %} {% if href %} {% if icon %}{{ icon | icon }}{% end %} {{ label }} {% else %} {% end %} {% end %} {% def button_group(cls="") %}