{% macro onsLabel(params) %}
    {% if params.id %}
        {% set descriptionId = params.id ~ "-description-hint" %}
    {% else %}
        {% set descriptionId = "description-hint" %}
    {% endif %}

    {% if params.inputType == "checkbox" or params.inputType == "radio" %}
        {% set isCheckboxOrRadio = true %}
    {% else %}
        {% set isCheckboxOrRadio = false %}
    {% endif %}

    {%- set description -%}
        <span
            {% if isCheckboxOrRadio == false %}id="{{ descriptionId }}"{% endif %}class="ons-label__description{% if params.inputType %}{{ ' ' }}ons-{{ params.inputType }}__label--with-description{% else %}{{ ' ' }}ons-input--with-description{% endif %}"
        >
            {{- params.description -}}
        </span>
    {%- endset -%}

    {%- if params.description and params.accessiblePlaceholder -%}
        {{- description | safe -}}
    {%- else -%}

        {%- if isCheckboxOrRadio == true -%}
            {%- set ariaHiddenDescription -%}
                <span class="ons-label__aria-hidden-description" aria-hidden="true">{{- description | safe -}}</span>
            {%- endset -%}

            {%- set description -%}
                <span class="ons-label__visually-hidden-description ons-u-vh" id="{{ descriptionId }}">{{- params.description -}}</span>
            {%- endset -%}
        {%- endif -%}

        <label
            class="{{ 'ons-label' if params.inputType is not defined }}{{ ' ' + params.classes if params.classes else '' }}{{ ' ons-label--with-description' if params.description }}{{ ' ons-label--placeholder' if params.accessiblePlaceholder }}"
            for="{{ params.for }}"
            {% if params.description %}aria-describedby="{{ descriptionId }}"{% endif %}
            {% if params.id %}id="{{ params.id }}"{% endif %}
            {% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ ' ' }}{{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}
        >
            {{- params.text | safe -}}

            {%- if isCheckboxOrRadio == true and params.description -%}
                {{- ariaHiddenDescription | safe -}}
            {%- endif -%}
        </label>
        {%- if params.description -%}
            {{- description | safe -}}
        {%- endif -%}
    {%- endif -%}
{% endmacro %}
