public static function WebformAccessibilityHelper::buildVisuallyHidden in Webform 8.5
Same name and namespace in other branches
- 6.x src/Utility/WebformAccessibilityHelper.php \Drupal\webform\Utility\WebformAccessibilityHelper::buildVisuallyHidden()
Visually hide text using .visually-hidden class.
The .visually-hidden class is used to render invisible content just for screen reader users.
Parameters
string|array $title: Text or #markup that should be visually hidden.
Return value
array A renderable array with the text wrapped in <span class="visually-hidden">
See also
https://webaim.org/techniques/css/invisiblecontent/
5 calls to WebformAccessibilityHelper::buildVisuallyHidden()
- WebformElementStates::processWebformStates in src/
Element/ WebformElementStates.php - Expand an email confirm field into two HTML5 email elements.
- WebformLikert::formatHtmlItem in src/
Plugin/ WebformElement/ WebformLikert.php - Format an element's value as HTML.
- WebformLikert::processWebformLikert in src/
Element/ WebformLikert.php - Processes a likert scale webform element.
- WebformMultiple::buildElementHeader in src/
Element/ WebformMultiple.php - Build a single element header.
- webform_preprocess_details in includes/
webform.theme.inc - Implements hook_preprocess_details() for details element templates.
File
- src/
Utility/ WebformAccessibilityHelper.php, line 25
Class
- WebformAccessibilityHelper
- Helper class webform accessibility methods.
Namespace
Drupal\webform\UtilityCode
public static function buildVisuallyHidden($title) {
if (is_array($title)) {
return $title + [
'#prefix' => '<span class="visually-hidden">',
'#suffix' => '</span>',
];
}
else {
return [
'#markup' => $title,
'#prefix' => '<span class="visually-hidden">',
'#suffix' => '</span>',
];
}
}