Skip to content

Storybook: Fix the color contrast of the Max-Width Wrapper label - #86475

Merged
mirka merged 3 commits into
WordPress:trunkfrom
Pathan-Amaankhan:fix/storybook-max-width-wrapper-contrast
Nov 10, 2026
Merged

mirka merged 3 commits into
WordPress:trunkfrom
Pathan-Amaankhan:fix/storybook-max-width-wrapper-contrast

Conversation

@Pathan-Amaankhan

@Pathan-Amaankhan Pathan-Amaankhan commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #86474

Restyles the "Max-Width Wrapper - …px" label that Storybook shows under a story when a Max-Width Wrapper is selected, using design tokens so it passes the color-contrast check and follows the selected theme.

Why?

The label used #757575 on #e0e0e0 at 11px, a contrast ratio of 3.49:1. That fails the 4.5:1 color-contrast check, so the Accessibility panel reported a serious violation for any story shown with a wrapper, even though the label belongs to Storybook and not to a component.

The hard-coded colors also didn't follow the theme switcher, so the label looked the same in every theme.

The wrapper defaults to "None", so the story accessibility checks normally run without the label.

How?

Replaces the hard-coded colors in storybook/decorators/with-max-width-wrapper.module.scss with the muted combination suggested in the review: --wpds-color-foreground-content-neutral-weak text on --wpds-color-background-surface-neutral, with a --wpds-color-stroke-surface-neutral border. The tokens follow the theme selected in the toolbar. box-sizing: border-box keeps the label 32px tall now that it has a border.

Testing Instructions

  1. Run npm run storybook:dev and open any story, for example, Components / @wordpress/ui / Badge / Default.
  2. In the toolbar, set Max-Width Wrapper to "Large container".
  3. Open the Accessibility panel and check that it reports no color-contrast violation for the "Max-Width Wrapper - 960px" label.

Testing Instructions for Keyboard

Not applicable: this only changes the look of a label.

Screenshots or screencast

Before After
Screenshot 2026-11-09 at 2 00 42 AM Screenshot 2026-11-09 at 10 03 13 PM

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

👋 Welcome

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Pathan-Amaankhan! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Pathan-Amaankhan <akrocks@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 8, 2026

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have design tokens now, I'm thinking we can just use them here too instead of hardcoding the colors, which won't work across themes in the theme switcher. Here's a proposed combination:

muted band

@Pathan-Amaankhan

Pathan-Amaankhan commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @mirka, that's a better fit.

In 3e3c885, I switched the label to the muted combination: content-neutral-weak text on surface-neutral, with a stroke-surface-neutral border, plus box-sizing: border-box so the height stays 32px.

I checked it with axe in the light, dark, and two custom themes, and the Max-Width Wrapper label itself reports no color-contrast violation in any of them.

@mirka mirka added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Developer Documentation Documentation for developers Storybook Storybook and its stories for components labels Nov 10, 2026
@mirka
mirka merged commit 4411e5c into WordPress:trunk Nov 10, 2026
87 of 88 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Storybook Storybook and its stories for components [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Storybook: Max-Width Wrapper label fails color contrast in the Accessibility panel

2 participants