Accessibility in React Tooltip component

24 Jan 20244 minutes to read

The Tooltip component followed 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 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 Tooltip component followed the WAI-ARIA patterns to meet the accessibility. The following ARIA attributes are used in the Tooltip component.

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

In case, the target element already holds an aria-describedby attribute with Id value of some other component, then the 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 Tooltip component.

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

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

Keyboard interaction

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

Keys Description
Escape Closes or dismisses the Tooltip.
Tab A form control receiving focus (say through tab key), opens the Tooltip, and on focus out closes it.
  1. When the Tooltip is being displayed on the target element, focus continues to stay on it.
  2. If the 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 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 Tooltip opens on a click, then it should be closed only on another click action.

Ensuring accessibility

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

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

See also