Accessibility in React Tooltip

4 Sep 20264 minutes to read

The React Tooltip component follows the accessibility guidelines and standards, including ADA, Section 508, WCAG 2.2 standards, and WCAG roles that are commonly used to evaluate accessibility.

The accessibility compliance for the React Tooltip component is outlined below.

Accessibility Criteria Compatibility
WCAG 2.2 Support Yes
Section 508 Support Yes
Screen Reader Support Yes
Right-To-Left Support Yes
Color Contrast Yes
Mobile Device Support Yes
Keyboard Navigation Support Yes
Accessibility Checker Validation Yes
Axe-core Accessibility Validation Yes
Yes - All features of the component meet the requirement.
Intermediate - Some features of the component do not meet the requirement.
No - The component does not meet the requirement.

WAI-ARIA attributes

The React Tooltip component follows the WAI-ARIA patterns to meet the accessibility. The following ARIA attributes are used in the React Tooltip component.

Attributes Description
role=”tooltip” The element that serves as the container for the React Tooltip has the ARIA role of tooltip.
aria-describedby This attribute is added to the target element on which the React Tooltip gets opened, when focusing or hovering over it. It usually holds the randomly generated Id value of the React Tooltip element.

In case, the target element already holds an aria-describedby attribute with Id value of some other component, then the React Tooltip Id value can be additionally appended to the existing aria-describedby attribute separated by a space as shown in the example below.

For example:
aria-describedby = “my-text my-tooltip”
my-text is the Id of some other component.
my-tooltip is the id of React Tooltip component.

When the React Tooltip is closed, the aria-describedby attribute is removed from the target.
aria-hidden This attribute is assigned to the React Tooltip element whose default value is true.

When true, it denotes that the React Tooltip element is in a hidden or a closed state. When the React Tooltip appears on the screen, it’s value changes to false.

Keyboard interaction

The React Tooltip component follows the keyboard interaction guideline, making it easy for people who use assistive technologies (AT) and those who completely rely on keyboard navigation. The React Tooltip component supports the following keyboard shortcuts.

Keys Description
Escape Closes or dismisses the React Tooltip.
Tab A form component receiving focus (say through tab key), opens the React Tooltip, and on focus out closes it.
  1. When the React Tooltip is being displayed on the target element, focus continues to stay on it.
  2. If the React Tooltip opens on mouse entering into the target element space, then it should be dismissed only when the mouse leaves that target.
  3. If the React Tooltip opens on the target element that receives focus, then it should be closed only when the focus moves out of that target element.
    Likewise, if the React Tooltip opens on a click, then it should be closed only on another click action.

Ensuring accessibility

The React Tooltip component’s accessibility levels are ensured through an accessibility-checker and axe-core software tools during automated testing.

The accessibility compliance of the React Tooltip component is shown in the following sample. Open the sample in a new window to evaluate the accessibility of the React Tooltip component with accessibility tools.

See also