Skip to content

tabIndexPositiveValues

Reports positive tabIndex values.

✅ This rule is included in the jsx logical and logicalStrict presets.

Positive tabIndex values disrupt the natural tab order and make keyboard navigation unpredictable for users. Instead, use tabIndex="0" to include elements in the natural tab order, or tabIndex="-1" to make them programmatically focusable.

This is required for WCAG 2.4.3 compliance.

<
JSX.IntrinsicElements.span: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
span
tabIndex="5">content</
JSX.IntrinsicElements.span: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
span
>
Error ts(2322) ― Type 'string' is not assignable to type 'number'.
<
JSX.IntrinsicElements.span: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
span
tabIndex="1">content</
JSX.IntrinsicElements.span: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>
span
>
Error ts(2322) ― Type 'string' is not assignable to type 'number'.
<
JSX.IntrinsicElements.div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
HTMLAttributes<HTMLDivElement>.tabIndex?: number | undefined
tabIndex
={3}>content</
JSX.IntrinsicElements.div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
>

If you are managing tab orders with a well-defined focus management system that handles positive tabIndex values well, this rule may not be applicable.

Made with ❤️‍🔥 around the world by the Flint team and contributors.