{# Form Components Macros: text_input, textarea_input, select_input, checkbox, toggle, button, icon_button, form_group #} {% macro text_input(name, label="", value="", placeholder="", type="text", required=false, disabled=false, help="") %}
{% if label %} {% endif %} {% if help %}

{{ help }}

{% endif %}
{% endmacro %} {% macro textarea(name, label="", value="", placeholder="", rows=4, required=false, disabled=false) %}
{% if label %} {% endif %}
{% endmacro %} {% macro select_input(name, options, label="", selected="", required=false, disabled=false) %}
{% if label %} {% endif %}
{% endmacro %} {% macro checkbox(name, label, checked=false, disabled=false) %} {% endmacro %} {% macro toggle(name, label, checked=false, disabled=false) %} {% endmacro %} {% macro button(text, type="button", variant="primary", icon="", disabled=false, size="md", full_width=false) %} {% set base_classes = "rounded-lg font-medium flex items-center justify-center gap-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed" %} {% set variant_classes = { "primary": "bg-[#238636] hover:bg-[#2ea043] text-white", "secondary": "bg-[#21262d] hover:bg-[#30363d] text-white", "danger": "bg-[#da3633] hover:bg-[#f85149] text-white", "ghost": "hover:bg-[#21262d] text-[#8b949e] hover:text-white" } %} {% set size_classes = { "sm": "px-3 py-1.5 text-xs", "md": "px-4 py-2 text-sm", "lg": "px-6 py-3 text-base" } %} {% endmacro %} {% macro icon_button(icon, title="", variant="ghost", size="md", disabled=false) %} {% set base_classes = "rounded-lg flex items-center justify-center transition-colors disabled:opacity-50" %} {% set variant_classes = { "primary": "bg-[#238636] hover:bg-[#2ea043] text-white", "secondary": "bg-[#21262d] hover:bg-[#30363d] text-white", "danger": "bg-[#da3633] hover:bg-[#f85149] text-white", "ghost": "hover:bg-[#21262d] text-[#8b949e] hover:text-white" } %} {% set size_classes = { "sm": "p-1.5", "md": "p-2", "lg": "p-3" } %} {% set icon_sizes = { "sm": "w-3 h-3", "md": "w-4 h-4", "lg": "w-5 h-5" } %} {% endmacro %} {% macro alpine_input(model, label="", type="text", placeholder="", mono=false, help="") %} {# Alpine.js reactive input with x-model binding. Use inside x-data scopes. Unlike text_input(), this does NOT use name/value — it binds to Alpine state. Args: model: Alpine x-model expression (e.g. "form.name") label: Label text type: Input type (text, number, password, email) placeholder: Placeholder text mono: Use monospace font help: Help text below input #}
{% if label %} {% endif %} {% if help %}

{{ help }}

{% endif %}
{% endmacro %} {% macro alpine_select(model, options, label="") %} {# Alpine.js reactive select with x-model binding. Args: model: Alpine x-model expression options: List of {value, label} dicts OR simple strings label: Label text #}
{% if label %} {% endif %}
{% endmacro %} {% macro alpine_textarea(model, label="", placeholder="", rows=4, mono=false) %} {# Alpine.js reactive textarea with x-model binding. Args: model: Alpine x-model expression label: Label text placeholder: Placeholder text rows: Number of rows mono: Use monospace font #}
{% if label %} {% endif %}
{% endmacro %} {% macro form_group(label="", help="", error="") %} {# Wrapper for form fields with label, help text, and error #}
{% if label %} {% endif %} {{ caller() }} {% if help and not error %}

{{ help }}

{% endif %} {% if error %}

{{ error }}

{% endif %}
{% endmacro %}