Skip to main content
React Doctor includes 15 accessibility rules from the jsx-a11y plugin to help you build interfaces that work for everyone.

Why Accessibility Matters

  • 15% of the world has some form of disability
  • Legal requirement in many jurisdictions (ADA, Section 508, WCAG)
  • Better UX for everyone (keyboard nav, screen readers, low vision)
  • SEO benefits from semantic HTML

Rules

Severity: error
Rule ID: jsx-a11y/alt-text
Requires alt attribute on <img> elements. Screen readers use alt text to describe images.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/anchor-is-valid
Ensures <a> elements have valid href attributes. Links without hrefs should be buttons.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/click-events-have-key-events
Requires keyboard event handlers alongside click handlers for accessibility.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/no-static-element-interactions
Prevents adding click/keyboard handlers to non-interactive elements without proper ARIA roles.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/no-noninteractive-element-interactions
Prevents adding interactions to non-interactive elements like <li>, <article>, etc.Bad:
Good:
Severity: error
Rule ID: jsx-a11y/role-has-required-aria-props
Ensures ARIA roles have all required ARIA attributes.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/no-autofocus
Discourages autoFocus as it can be disorienting for screen reader users.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/heading-has-content
Requires heading elements to have content for screen readers.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/html-has-lang
Requires <html> element to have lang attribute for screen readers.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/no-redundant-roles
Prevents specifying redundant ARIA roles that are implicit.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/scope
Ensures scope attribute is only used on <th> elements in tables.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/tabindex-no-positive
Prevents positive tabIndex values which disrupt natural tab order.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/label-has-associated-control
Requires <label> elements to be associated with form controls.Bad:
Good:
Severity: error
Rule ID: jsx-a11y/no-distracting-elements
Prevents using distracting elements like <marquee> and <blink>.Bad:
Good:
Severity: warn
Rule ID: jsx-a11y/iframe-has-title
Requires <iframe> elements to have a title attribute.Bad:
Good:

Accessibility Best Practices

Semantic HTML

Use the right element for the job:

Keyboard Navigation

Ensure all interactive elements are keyboard accessible:
  • Use semantic HTML (<button>, <a>, <input>)
  • Add tabIndex={0} for custom interactive elements
  • Handle Enter and Space keys for custom controls
  • Provide visible focus indicators

Screen Readers

Make content accessible to screen readers:
  • Use alt text for images
  • Label form inputs
  • Use ARIA labels when needed: aria-label, aria-labelledby
  • Provide aria-live regions for dynamic content
  • Use proper heading hierarchy (h1h2h3)

Color and Contrast

  • Maintain 4.5:1 contrast ratio for text
  • Don’t rely on color alone to convey information
  • Test with color blindness simulators

Testing Tools