@wcag-checkr/storybook-addon
v1.6.1
Published
Multi-state accessibility audit for Storybook. Cycles each story through default, hover, focus, and dark-mode states, runs axe-core at each, and surfaces per-state findings in a Storybook panel. Companion to the wcagcheckr Chrome extension.
Maintainers
Readme
@wcag-checkr/storybook-addon
Multi-state accessibility audit for Storybook. Cycles each story through default, hover, focus, and dark-mode states, runs axe-core at each, and reports per-state findings in a Storybook panel.
Companion to the wcagcheckr Chrome extension — the extension drives the FULL state matrix (forced-colors, RTL, real :focus-visible, multiple breakpoints) via the Chrome DevTools Protocol; this addon does what's possible from inside a Storybook preview iframe.
Install
npm install --save-dev @wcag-checkr/storybook-addonAdd to your .storybook/main.ts:
import type { StorybookConfig } from '@storybook/react-vite';
const config: StorybookConfig = {
stories: ['../src/**/*.stories.@(ts|tsx)'],
addons: [
'@storybook/addon-essentials',
'@wcag-checkr/storybook-addon',
],
framework: { name: '@storybook/react-vite', options: {} },
};
export default config;Use
Open any story → click the wcagcheckr panel → click Run multi-state audit.
Per-state findings appear under each state heading. Pass = no axe-core violations at that state; fail = one or more, with the rule, impact level, affected node count, and a link to the rule documentation.
How states are simulated
| State | Mechanism | Reliability |
|---|---|---|
| default | No attribute on <html>. Ambient state. | High |
| hover | <html data-wc-state="hover"> — opt-in via your CSS | Medium |
| focus | <html data-wc-state="focus"> — opt-in via your CSS | Medium |
| dark | <html class="dark" data-theme="dark"> | High when your CSS targets either selector |
If your CSS only uses :hover / :focus pseudo-class selectors (not class-based mirrors), the hover/focus states will run axe-core but the visible style won't change. That still catches non-pseudo-class violations (contrast at rest, ARIA, names/labels) — useful but limited.
For the FULL multi-state matrix (forced-colors, RTL, real focus-visible, breakpoints, ARIA-state permutations), install the wcagcheckr Chrome extension — it drives the rendered component through every state via the Chrome DevTools Protocol, which a Storybook preview iframe cannot.
License
UNLICENSED until commercial release. See wcagcheckr.com/license.
