Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add streamlined a11y setup docs #29296

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/_snippets/storybook-a11y-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```shell renderer="common" language="js" packageManager="npm"
npx storybook add @storybook/addon-a11y
```

```shell renderer="common" language="js" packageManager="pnpm"
pnpm exec storybook add @storybook/addon-a11y
```

```shell renderer="common" language="js" packageManager="yarn"
yarn exec storybook add @storybook/addon-a11y
```
1 change: 0 additions & 1 deletion docs/_snippets/storybook-a11y-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ pnpm add --save-dev @storybook/addon-a11y
```shell renderer="common" language="js" packageManager="yarn"
yarn add --dev @storybook/addon-a11y
```

1 change: 0 additions & 1 deletion docs/_snippets/storybook-a11y-register.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ const config: StorybookConfig = {

export default config;
```

14 changes: 5 additions & 9 deletions docs/writing-tests/accessibility-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,19 @@ Storybook provides an official [a11y addon](https://storybook.js.org/addons/@sto

### Set up the a11y addon

If you want to check accessibility for your stories using the [addon](https://storybook.js.org/addons/@storybook/addon-a11y/), you'll need to install it and add it to your Storybook.

Run the following command to install the addon.
If you want to check accessibility for your stories using the [addon](https://storybook.js.org/addons/@storybook/addon-a11y/), you'll need to add it to your Storybook. You can do this by running the following command:

{/* prettier-ignore-start */}

<CodeSnippets path="storybook-a11y-install.md" />
<CodeSnippets path="storybook-a11y-add.md" />

{/* prettier-ignore-end */}

Update your Storybook configuration (in `.storybook/main.js|ts`) to include the accessibility addon.

{/* prettier-ignore-start */}
<Callout variant="info">

<CodeSnippets path="storybook-a11y-register.md" />
The CLI's [`add`](../api/cli-options.mdx#add) command automates the addon's installation and setup. To install it manually, see our [documentation](../addons/install-addons.mdx#manual-installation) on how to install addons.

{/* prettier-ignore-end */}
</Callout>

Start your Storybook, and you will see some noticeable differences in the UI. A new toolbar icon and the accessibility panel where you can inspect the results of the tests.

Expand Down