diff -u b/src/Plugin/Preprocess/FormElementLabel.php b/src/Plugin/Preprocess/FormElementLabel.php --- b/src/Plugin/Preprocess/FormElementLabel.php +++ b/src/Plugin/Preprocess/FormElementLabel.php @@ -23,12 +23,6 @@ * {@inheritdoc} */ public function preprocessElement(Element $element, Variables $variables) { - // Labels for single checkboxes/radios contain the element itself and thus - // have always to be rendered regardless of whether they have a title. - if ($element->getProperty('is_checkbox') || $element->getProperty('is_radio')) { - $variables['allow_empty'] = TRUE; - } - // Map the element properties. $variables->map(['attributes', 'is_checkbox', 'is_radio']); diff -u b/starterkits/sass/sass/component/_form.scss b/starterkits/sass/sass/component/_form.scss --- b/starterkits/sass/sass/component/_form.scss +++ b/starterkits/sass/sass/component/_form.scss @@ -4,13 +4,11 @@ // Checkboxes / radio buttons. .checkbox, .radio { - &.form-no-label { - // Remove top/bottom margins when in table context, because this is most - // likely a tableselect checkbox element. - table & { - margin-bottom: 0; - margin-top: 0; - } + // Remove top/bottom margins when in table context, because this is most + // likely a tableselect checkbox element. + table &.form-no-label { + margin-bottom: 0; + margin-top: 0; } } diff -u b/templates/input/form-element-label.html.twig b/templates/input/form-element-label.html.twig --- b/templates/input/form-element-label.html.twig +++ b/templates/input/form-element-label.html.twig @@ -11,7 +11,6 @@ * - required: An indicator for whether the associated form element is required. * - is_checkbox: Whether the label is outputted in checkbox context. * - is_radio: Whether the label is outputted in radio button context. - * - allow_empty: Whether ouput the label even if the actual title is empty. * - attributes: A list of HTML attributes for the label. * * @ingroup templates @@ -29,10 +28,18 @@ ] -%} {% if title is not empty and title_display == 'invisible' and (is_checkbox or is_radio) -%} - {%- set attributes = attributes.setAttribute('title', title) -%} {%- set title = null -%} + {# + Preserve label text as attribute (e.g. for screen readers) for + checkboxes/radio buttons when it actually should be invisible. + #} + {%- set attributes = attributes.setAttribute('title', title) -%} {%- endif -%} -{%- if title is not empty or allow_empty -%} +{# +Labels for single checkboxes/radios contain the element itself and thus have +always to be rendered regardless of whether they have a title or not. +#} +{%- if title is not empty or is_checkbox or is_radio -%} {{ element }}{{ title }} {%- if description -%}

{{ description }}