{#- 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 size = (size or "") | validate_size("btn", "") %} {% 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 %} {% if href %} {% if icon %}{{ icon | icon }}{% end %} {{ label }} {% else %} {% end %} {% end %} {% def button_group(cls="") %}
{% slot %}
{% end %}