Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-a11y

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-a11y

Warns about potential accessibility issues with your React elements.

  • 0.2.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
3
Weekly downloads
 
Created
Source

React A11y

build status

Warns about potential accessibility issues with your React elements.

screenshot

WIP

This is a WIP, feel free to explore, open issues, and suggest assertions :)

Installation

npm install react-a11y

Usage

In your main application file, require and call the module, you'll start getting warnings in the console as your app renders.

var a11y = require('react-a11y');
if (ENV === 'development') a11y(React);

You probably don't want to call it if you're in production, and better yet, alias the module to nothing with webpack in production.

If you want it to throw errors instead of just warnings:

a11y(React, { throw: true });

You can filter failures by passing a function to the filterFn option. The filter function will receive three arguments: the name of the Component instance or ReactElement, the id of the element, and the failure message. Note: If a ReactElement, the name will be the node type followed by the id (e.g. div#foo).

var commentListFailures = (name, id, msg) => {
  return name === "CommentList";
};

a11y(React, { filterFn: commentListFailures });

If you want to log DOM element references for easy lookups in the DOM inspector, use the includeSrcNode option.

a11y(React, { throw: true, includeSrcNode: true });

Some test are only relevant for certain device types. For example, if you are building a mobile web app, you can filter out desktop-specific rules by specifying a specific device type:

a11y(React, { device: ['mobile'] });

It's also possible exclude certain tests:

a11y(React, { exclude: ['REDUNDANT_ALT'] });

Keywords

FAQs

Package last updated on 30 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc