{#
/**
 * @file
 * Default theme implementation for a form element label.
 *
 * Available variables:
 * - element: an input element.
 * - title: The label's text.
 * - title_display: Elements title_display setting.
 * - description: element description.
 * - required: An indicator for whether the associated form element is required.
 * - attributes: A list of HTML attributes for the label.
 *
 * @see template_preprocess_form_element_label()
 *
 * @ingroup templates
 */
#}

{%-
    set classes = [
    'control-label',
    title_display == 'after' ? 'option',
    title_display == 'invisible' ? 'sr-only',
    title_display == 'above' ? 'control-label--above',
    required ? 'js-form-required',
    required ? 'form-required',
]
-%}

{{ element }}
{%- if title is not empty -%}
  <label{{ attributes.addClass(classes) }}>
    {%- if icon is not empty -%}
      <svg class="icon-small" aria-hidden="true">
        <use xlink:href="#icon-{{ icon }}"></use>
      </svg>
      <span>{{ title }}</span>
    {%- else -%}
      {{ title }}
    {%- endif -%}

    {%- if required and title_display != 'invisible' -%}
        <span class="form-required" title="{% trans %}This field is required{% endtrans %}">*</span>
    {%- endif -%}
    {%- if description -%}
      <p class="help-block">{{ description }}</p>
    {%- endif -%}
  </label>
{%- endif -%}
