src/content/docs/linter/rules/no-noninteractive-tabindex.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JSX and TSX" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/a11y/noNoninteractiveTabindex`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`jsx-a11y/no-noninteractive-tabindex`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/no-noninteractive-tabindex.md){
"linter": {
"rules": {
"a11y": {
"noNoninteractiveTabindex": "error"
}
}
}
}
Enforce that tabIndex is not assigned to non-interactive HTML elements.
When using the tab key to navigate a webpage, limit it to interactive elements. You don't need to add tabindex to items in an unordered list as assistive technology can navigate through the HTML. Keep the tab ring small, which is the order of elements when tabbing, for a more efficient and accessible browsing experience.
<div tabIndex="0" />
<div role="article" tabIndex="0" />
<article tabIndex="0" />
<div />
<MyButton tabIndex={0} />
<article tabIndex="-1" />