{% props variant = 'default', # primary|default|danger|success|warning (default: 'default') isInvisible = false, # true|false (default: false) if true, button has transparent background and no border isBlock = false, # true|false (default: false) if true, button takes full width of container size = 'md', # sm|md|lg (default: 'md') icon = null, # icon name string (e.g., 'tabler:user' or 'fa fas fa-user') withTrailingIcon = false, # boolean to show icon after label (default: false) inactive = false, # boolean to disable the button (default: false) htmlElement = 'button', # button|a|form (default: 'button') htmlAttributes = {}, # additional HTML attributes as key-value pairs href = '#', # URL for link buttons (default: '#') action = null, # form action URL (for htmlElement='form') method = 'POST', # HTTP method for forms (default: 'POST') type = null, # button|submit (default: 'submit') button type attribute name = null, # form button name attribute value = null, # form button value attribute %} {# handle both string and enum values #} {% set html_element_value = htmlElement.value is defined ? htmlElement.value : htmlElement %} {% set variant_value = variant.value is defined ? variant.value : variant %} {% set variant_class = variant_value == 'default' ? 'btn-secondary' : 'btn-' ~ variant_value %} {% set size_class = size == 'md' ? '' : 'btn-' ~ size %} {% set css_class = html_classes('btn', variant_class, size_class, { 'btn-invisible': isInvisible, 'btn-block': isBlock, 'disabled': inactive, }) %} {% if html_element_value == 'a' %} {% if icon and not withTrailingIcon %} {% endif %} {% if block('content') is defined %} {{ block('content') }} {% endif %} {% if icon and withTrailingIcon %} {% endif %} {% elseif html_element_value == 'form' %}
{% if method|upper not in ['GET', 'POST'] %} {% endif %}
{% else %} {% endif %}