no-aria-hidden-on-focusable
Configuration
rslint.config.ts
Rule Details
Disallow aria-hidden="true" from being set on focusable elements. An
element with aria-hidden="true" is removed from the accessibility tree, so
a screen reader will skip it; if the element is still in the focus order,
keyboard and screen-reader users can land on a control that announces
nothing, causing confusion.
The rule fires on a JSX element when both of the following hold:
- The
aria-hiddenprop resolves to JS booleantrue. The boolean attribute form (<div aria-hidden />), the case-insensitive strings"true"/"True"/"TRUE", the explicit{true}, and any expression that statically evaluates totrueall count. - The element is focusable per
aria-query's element-role map:- Inherently interactive elements (
<button>,<input>,<textarea>,<select>,<a href>,<area href>, ...) are focusable unlesstabIndexresolves to a negative integer. - Non-interactive elements (
<div>,<span>,<p>, ...) and custom components become focusable only whentabIndexresolves to a non-negative integer.
- Inherently interactive elements (
This rule takes no options.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Resources
- Deque University —
aria-hiddenelements do not contain focusable elements - W3C ACT — Element with
aria-hiddenhas no content in sequential focus navigation - MDN —
aria-hidden