Package Exports
- @storybook/addon-a11y
- @storybook/addon-a11y/dist/index.js
- @storybook/addon-a11y/register
- @storybook/addon-a11y/register.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@storybook/addon-a11y) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
storybook-addon-a11y
This storybook addon can be helpful to make your UI components more accessible.

Getting started
First, install the addon.
$ yarn add @storybook/addon-a11y --devAdd this line to your main.js file (create this file inside your storybook config directory if needed).
module.exports = {
addons: ['@storybook/addon-a11y'],
};import React from 'react';
export default {
title: 'button',
};
export const accessible = () => <button>Accessible button</button>;
export const inaccessible = () => (
<button style={{ backgroundColor: 'red', color: 'darkRed' }}>Inaccessible button</button>
);If you wish to selectively disable a11y checks for a subset of stories, you can control this with story parameters:
export const MyNonCheckedStory = () => <SomeComponent />;
MyNonCheckedStory.parameters = {
a11y: { disable: true },
};Parameters
For more customizability use parameters to configure aXe options. You can override these options at story level too.
import React from 'react';
import { storiesOf, addDecorator, addParameters } from '@storybook/react';
export default {
title: 'button',
parameters: {
a11y: {
// optional selector which element to inspect
element: '#root',
// axe-core configurationOptions (https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#parameters-1)
config: {},
// axe-core optionsParameter (https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#options-parameter)
options: {},
// optional flag to prevent the automatic check
manual: true,
},
},
};
export const accessible = () => <button>Accessible button</button>;
export const inaccessible = () => (
<button style={{ backgroundColor: 'red', color: 'darkRed' }}>Inaccessible button</button>
);Roadmap
- Make UI accessible
- Show in story where violations are.
- Add more example tests
- Add tests
- Make CI integration possible