--- id: Helper text section: components --- import { Checkbox, List, ListItem } from '@patternfly/react-core'; ## Accessibility To implement an accessible PatternFly **helper text**: - Give the helper text item an `id`, and pass that `id` to the main element's `aria-describedby` attribute. Alternatively if there are multiple helper text items, the helper text component can be given the `id` to be passed to the main element's `aria-describedby`. For example, the following code block includes two valid examples of passing `id` values to a main element: ```noLive Some helper text content Some helper text content Some other helper text content ``` - Structure the helper text as a `ul` element and each helper text item as a `li` element if there is more than one helper text item. - Make the helper text component an `aria-live` region if the helper text item(s) have static text and styling, but will dynamically render. - Ensure there is visually hidden text for assistive technologies such as screen readers that conveys the status type if: - the helper text item has static text and will always be rendered, but the styling will dynamically update, or - the helper text item text content itself doesn't convey a status type - Avoid passing interactive content as helper text. ## Testing At a minimum, a helper text should meet the following criteria: Each helper text item has an id attribute, whose value is also passed to the main element's aria-describedby attribute.} description="This allows a user navigating via assistive technologies such as a screen reader to have the helper text content announced to them without having to move focus from the main element." /> If there are multiple helper text items, the helper text component is structured as a ul element and the helper text items are structured as li elements.} description="This lets users known how many helper text items there are within a single helper text component when navigating via assistive technologies such as a screen reader." /> The aria-live value should be "polite" when doing so. This will announce to users of assistive technologies when new helper text has rendered, keeping them informed of any remaining criteria or issues that need to be addressed.} /> This is best achieved by using our pf-v6-screen-reader class.} /> ## React customization The following React props have been provided for more fine-tuned control over accessibility. | Prop | Applied to | Reason | |---|---|---| | `aria-label="[text that labels a helper text list]"` | `HelperText` | Adds an accessible name to the helper text component. Should only be passed when the `component` prop has a value of `"ul"`, especially when there are multiple helper text components on a page. Doing so will help differentiate the lists for users navigating via rotor menus. | | `component="ul"` | `HelperText` | Sets the wrapper element of the helper text component to an unordered list. **Required** when the helper text component is intended or expected to include multiple helper text items. | | `id` | `HelperText` | Sets the `id` attribute of the helper text component, which can be passed to the main element's `aria-describedby` attribute when there are multiple helper text items that should all be announced. | | `isLiveRegion` | `HelperText` | Makes the helper text component a live region with a value of `"polite"`. **Required** when helper text item(s) are intended or expected to have static text, but dynamically render. | | `component="li"` | `HelperTextItem` | Sets the wrapper element of the helper text item to a list item. **Required** when `HelperText` has `component="ul"` passed in. | | `id` | `HelperTextItem` | Sets the `id` attribute of the helper text item, which should be passed to the main element's `aria-describedby` attribute. | | `screenReaderText="[text that conveys status type]"` | `HelperTextItem` | Renders visually hidden text when the `isDynamic` prop is also passed in. Typically this should convey the status type of the helper text item, and will render immediately after the item text. This can be prevented from rendering by passing an empty string `''` as a value. | | `variant="[default, indeterminate, warning, error, or success]"` | `HelperTextItem` | Sets the text styling and icon. This prop should only be passed in when the helper text item should visually convey some sort of status. | ## HTML/CSS customization The following HTML attributes and PatternFly classes can be used for more fine-tuned control over accessibility. | Attribute or class | Applied to | Reason | |---|---|---| | `aria-label="[text that labels a helper text list]"` | `ul.pf-v6-c-helper-text` | Adds an accessible name to the helper text component. Should be passed when there are multiple helper text components on a page. Doing so will help differentiate the lists for users navigating via rotor menus. | | `aria-live="polite"` | `.pf-v6-c-helper-text` | Makes the helper text component a live region. **Required** when helper text item(s) are intended or expected to have static text, but dynamically render. | | `id` | `.pf-v6-c-helper-text` | Sets the `id` attribute of the helper text component, which can be passed to the main element's `aria-describedby` attribute when there are multiple helper text items that should all be announced. | | `role="list"` | `ul.pf-v6-c-helper-text` | Indicates that the helper text component is a list element. **Required**.

This role is redundant since `.pf-v6-c-helper-text` can be a `