A Comprehensive Guide to Implementing Accessibility in Storybook for Angular

Ahmadreza Shamimi
2 min readJun 1, 2023

--

To have accessibility testing in Storybook for each Angular component’s story, you can use addons such as ‘@storybook/addon-a11y’. This add-on helps check your stories for accessibility issues during development.

  1. Here are the steps to follow:

Installation: First, install the addon with the following command in your terminal:

npm install --save-dev @storybook/addon-a11y

or

yarn add --dev @storybook/addon-a11y

2. Register the addon: After installation, you need to register the addon. Add the following line in your .storybook/main.js file in the addons array:

module.exports = {
stories: ['../src/**/*.stories.[tj]s'],
addons: ['@storybook/addon-a11y'],
};

3. Viewing the results: After setting up the addon, you can view the accessibility testing results in the Storybook UI. When you open a story, you will find an “Accessibility” tab in the add-ons panel, which will display the results of the tests.

This addon is built using the ‘axe-core’ accessibility engine, and it will test your stories for common accessibility issues, such as color contrast, missing alt text for images, missing form labels, and more. Remember that automated testing can only catch some accessibility issues, and manual testing is still necessary for a truly accessible application.

Result in Action :

Accessibility Storybook V 7.0

--

--

Ahmadreza Shamimi
Ahmadreza Shamimi

Written by Ahmadreza Shamimi

I'm Ahmadreza Shamimi with an experienced with over 10 years of experience coding with web and mobile platforms.

No responses yet