bootstrap_storybook-8.x-2.0/src/components/form/form-element--label.twig
src/components/form/form-element--label.twig
{#
/**
* @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 = [
title_display == 'after' ? 'option',
title_display == 'invisible' ? 'visually-hidden',
required ? 'js-form-required',
required ? 'form-required',
]
-%}
{%- if title is not empty or required -%}
<label{{ attributes.addClass(classes) }}> {{ element }} {{ title }}
{%- if description -%}
<p class="help-block">{{ description }}</p>
{%- endif -%}
{%- if required and title_display == 'before' -%}
<span class="font-weight-bolder form-required--indicator pl-1 text-danger">*</span>
{%- endif -%}
</label>
{%- endif -%}
