interactiveElementsFocusable
Reports interactive elements that are not focusable via keyboard.
✅ This rule is included in the jsxlogicalandlogicalStrictpresets.
Elements with interactive roles and event handlers must be focusable. Users navigating with keyboards need to be able to reach all interactive elements. When interactive elements are not focusable, they become inaccessible to keyboard-only users.
This rule reports elements that have interactive roles (like button, link, etc.) and event handlers but lack a way to be focused via keyboard - either through being inherently focusable (like <button>) or having an explicit tabIndex attribute.
Examples
Section titled “Examples”<any
div role: string
role="button" onClick: () => void
onClick={() => {}} /><any
span role: string
role="link" onClick: () => void
onClick={() => {}} /><any
div role: string
role="checkbox" onClick: () => void
onClick={() => {}} /><any
div role: string
role="menuitem" onKeyDown: () => void
onKeyDown={() => {}} /><any
button onClick: () => void
onClick={() => {}} /><any
div role: string
role="button" tabIndex: number
tabIndex={0} onClick: () => void
onClick={() => {}} /><any
span role: string
role="link" tabIndex: number
tabIndex={0} onClick: () => void
onClick={() => {}} /><any
div role: string
role="menuitem" tabIndex: number
tabIndex={-1} onKeyDown: () => void
onKeyDown={() => {}} /><any
a href: string
href="#section" onClick: () => void
onClick={() => {}} />When Not To Use It
Section titled “When Not To Use It”If you are using a framework that automatically manages focus for interactive elements, you may want to disable this rule.
Further Reading
Section titled “Further Reading”- MDN: Keyboard-navigable JavaScript widgets
- WCAG 2.1.1: Keyboard
- WAI-ARIA Authoring Practices: Keyboard Navigation Conventions
Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 around the world by
the Flint team and contributors.