@storybook/addon-a11y
a11y addon for storybook
Last updated 5 years ago by shilman .
MIT · Repository · Bugs · Original npm
$ cnpm install @storybook/addon-a11y 
SYNC missed versions from official npm registry.

storybook-addon-a11y

This storybook addon can be helpful to make your UI components more accessible.

Framework Support

Screenshot

Getting started

First, install the addon.

$ yarn add @storybook/addon-a11y --dev

Add this line to your main.js file (create this file inside your storybook config directory if needed).

module.exports = {
  addons: ['@storybook/addon-a11y/register']
}

import the withA11y decorator to check your stories for violations within your components.

import React from 'react';

import { withA11y } from '@storybook/addon-a11y';

export default {
  title: 'button',
  decorators: [withA11y],
};

export const accessible = () => (
  <button>
    Accessible button
  </button>
);

export const inaccessible = () => (
  <button style={{ backgroundColor: 'red', color: 'darkRed', }}>
    Inaccessible button
  </button>
);

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';

import { withA11y } from '@storybook/addon-a11y';

export default {
  title: 'button',
  decorators: [withA11y],
  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: {},
    },
  },
};

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

Current Tags

  • 6.5.5                                ...           latest (3 years ago)
  • 6.5.0-rc.1                                ...           next (3 years ago)

11 Versions

  • 6.5.5-alpha.3                                ...           3 years ago
  • 6.5.0-rc.1                                ...           3 years ago
  • 6.5.5                                ...           3 years ago
  • 6.4.0-alpha.27                                ...           4 years ago
  • 6.0.28-alpha.3                                ...           5 years ago
  • 5.3.22                                ...           4 years ago
  • 6.1.0-alpha.9                                ...           5 years ago
  • 6.0.21                                ...           5 years ago
  • 5.3.21                                ...           5 years ago
  • 6.0.0-beta.27                                ...           5 years ago
  • 5.3.19                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (16)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org