Test component compliance with web accessibility standards
Core addon functionality providing the main export and parameter constants for integrating accessibility testing into Storybook.
The main addon export provides the entry point for Storybook addon configuration.
/**
* Main addon configuration function that returns preview configuration
* @returns Preview configuration object for Storybook
*/
declare const addon: () => any;
export default addon;Usage Example:
// In .storybook/main.js
export default {
addons: ['@storybook/addon-a11y']
};
// Or when importing programmatically
import a11yAddon from '@storybook/addon-a11y';
const config = a11yAddon();The parameter key used for configuring accessibility settings in stories and global parameters.
/**
* The parameter key for accessibility configuration
* Used in story parameters and global parameters
*/
export const PARAM_KEY: "a11y";Usage Example:
// Using the parameter key in story configuration
export const MyStory = {
parameters: {
[PARAM_KEY]: {
disable: false,
config: {
rules: [{ id: 'color-contrast', enabled: true }]
}
}
}
};
// Import and use the constant
import { PARAM_KEY } from '@storybook/addon-a11y';
console.log(PARAM_KEY); // "a11y"Configuration setup interface for accessibility testing.
/**
* Configuration setup interface for accessibility testing
* Defines element, config, and options properties
*/
export interface Setup {
element?: ElementContext;
config: Spec;
options: RunOptions;
}Usage Example:
import type { Setup } from '@storybook/addon-a11y';
const testSetup: Setup = {
element: '#main-content',
config: {
rules: [{ id: 'color-contrast', enabled: true }]
},
options: {
runOnly: ['wcag2a']
}
};Type definition for accessibility parameters used in story and global configuration.
/**
* Type definition for accessibility parameters
* Exported from main entry point for convenience
*/
export interface A11yParameters {
/**
* Accessibility configuration
*/
a11y?: {
/** Manual configuration for specific elements */
element?: ElementContext;
/** Configuration for the accessibility rules */
config?: Spec;
/** Options for the accessibility checks */
options?: RunOptions;
/** Remove the addon panel and disable the addon's behavior */
disable?: boolean;
};
};Usage Example:
import type { A11yParameters } from '@storybook/addon-a11y';
// Type-safe parameter configuration
const storyParameters: A11yParameters = {
a11y: {
config: {
rules: [
{ id: 'color-contrast', enabled: true },
{ id: 'keyboard-navigation', enabled: true }
]
},
options: {
runOnly: ['wcag2a', 'wcag2aa']
}
}
};Imported from axe-core, defines the element context for accessibility testing.
type ElementContext = string | Element | NodeList | Element[];Imported from axe-core, defines the configuration spec for accessibility rules.
interface Spec {
rules?: Array<{
id: string;
enabled?: boolean;
options?: any;
}>;
tags?: string[];
locale?: string;
}Imported from axe-core, defines the options for running accessibility tests.
interface RunOptions {
runOnly?: string[] | { type: string; values: string[] };
rules?: { [key: string]: { enabled: boolean } };
reporter?: string;
resultTypes?: string[];
selectors?: boolean;
ancestry?: boolean;
xpath?: boolean;
absolutePaths?: boolean;
}tessl i tessl/npm-storybook--addon-a11y@8.6.0