You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Styles editor should show color contrast failures. #48055
When modifying text and background colors in the post editor, low contrast color combinations trigger a color contrast warning. This does not occur in the style editor, though the global nature of these style changes are a much more significant accessibility issue than case-specific contrast failures.
What is your proposed solution?
The color contrast checker should be extended to the global styles editing experience, the Stylebook, etc.
Oh, this is an interesting one. Currently the ContrastChecker component only appears to be rendered within the color panel used in the block editor. There are some places where it could be tricky to introduce it (such as the style book) as it might not be very easy to determine which blocks result in poor color contrast.
However, in terms of introducing color contrast checking in global styles, probably a good place for us to start would be to look at the Colors screen. Since that screen is already looking up the global background and text colors, perhaps that could be a good initial place to introduce a color contrast warning?
Next steps could then be to introduce it to the Text, Background, and Heading color screens (where each screen would then need to do a lookup for the other color property for the contrast check — e.g. Text looks up Background, Heading looks up Background, Background looks up Text, etc)
screen-colors.js
screen-text-color.js
screen-background-color.js
If no-one beats me to it, I'll have a go at seeing how hard it'll be to introduce the color checker in those places, as I think that might get us a good part of the way there.
Reacted by Joe Dolson, Andy Peatling, Carolina Nymark and annezazu
I've had a go at adding in the ContrastChecker to the Background, Text, Links, and Colors screens in global styles, just for the root-level (not block-level) color screens. Happy for any feedback over in #48115
After having a go at using the existing ContrastChecker component for global styles over in #48115, the experiment revealed a few challenges that will likely require some design work before making another attempt:
The ContrastChecker looks at multiple dimensions of color contrast, and it's difficult to provide a suggestion at one screen (E.g. Background Color) that helpfully nudges the user as to what to change next, when the thing to change might be on another screen, e.g. Text or Link color. With the current component, in the experiment, each idea tried seemed to be more confusing for the user than having no message at all.
Feedback indicated that the parent Colors screen might be a more useful place to show the relationship between the different colors in use across the site. One potential direction was raised in this comment.(Global Styles: Add ContrastChecker to the Background, Text, Links, and Colors screens #48115 (comment)). Ideally, the messaging at this parent level should make it clear to the user which thing they need to address in order to restore good contrast in their site design.
The existing ContrastChecker component isn't flexible enough for the messaging / display requirements in the global styles screens. Before making another attempt, it might be worthwhile to refactor the component a little to extract the contrast checking logic into a hook. Then, perhaps global styles could use the hook to get the value of the contrast checker, and then use that value to flag within the UI which color values need changing.
In short, I think we need two steps to proceed:
Design work to figure out the right messaging / display of contrast issues in global styles colors screens
Extract contrast checking logic into a hook, so that custom messaging/display can be created within global styles
For more detail on the issues encountered in the first exploration, see this comment and screengrab: #48115 (comment)
There's a genuine technical questions on where in the matrix we are able to show the contrast checker, i.e. if you are editing your colour palette from Styles > Colors > Palette, you see simply n colour swatches and neither of them have any semantic meaning. We can see in the preview that "Color 1" is the background colour, and "Color 2" is the text colour, naturally those should have sufficient contrast. But without the semantic indication that one swatch has to another, I suspect it will be difficult to show anything in the Color section at all. If a dev has ideas here, I defer to you, but absent any magic we can make happen, what we could do is show a default notice (not dismissible), above or below the palette, something like:
Please be mindful to ensure sufficient color contrast between text and background. To be sure, visit the [Typography section], which can help check this.
In Styles > Typography, however, it seems like it should be possible to show a contrast checker. E.g. in Typography > Text you see this:
Absent implementation nuance, we could show the contrast checker in the colour flyout (as it exists in the post editor).
Activity
annezazu commentedon Feb 14, 2023
Calling on a crew to dive in and adding to the 6.2 board @tellthemachines @apeatling @andrewserong.
andrewserong commentedon Feb 15, 2023
Oh, this is an interesting one. Currently the
ContrastCheckercomponent only appears to be rendered within the color panel used in the block editor. There are some places where it could be tricky to introduce it (such as the style book) as it might not be very easy to determine which blocks result in poor color contrast.However, in terms of introducing color contrast checking in global styles, probably a good place for us to start would be to look at the Colors screen. Since that screen is already looking up the global background and text colors, perhaps that could be a good initial place to introduce a color contrast warning?
Next steps could then be to introduce it to the Text, Background, and Heading color screens (where each screen would then need to do a lookup for the other color property for the contrast check — e.g. Text looks up Background, Heading looks up Background, Background looks up Text, etc)
screen-colors.jsscreen-text-color.jsscreen-background-color.jsIf no-one beats me to it, I'll have a go at seeing how hard it'll be to introduce the color checker in those places, as I think that might get us a good part of the way there.
andrewserong commentedon Feb 16, 2023
I've had a go at adding in the
ContrastCheckerto the Background, Text, Links, and Colors screens in global styles, just for the root-level (not block-level) color screens. Happy for any feedback over in #48115andrewserong commentedon Feb 22, 2023
After having a go at using the existing
ContrastCheckercomponent for global styles over in #48115, the experiment revealed a few challenges that will likely require some design work before making another attempt:ContrastCheckerlooks at multiple dimensions of color contrast, and it's difficult to provide a suggestion at one screen (E.g. Background Color) that helpfully nudges the user as to what to change next, when the thing to change might be on another screen, e.g. Text or Link color. With the current component, in the experiment, each idea tried seemed to be more confusing for the user than having no message at all.ContrastCheckercomponent isn't flexible enough for the messaging / display requirements in the global styles screens. Before making another attempt, it might be worthwhile to refactor the component a little to extract the contrast checking logic into a hook. Then, perhaps global styles could use the hook to get the value of the contrast checker, and then use that value to flag within the UI which color values need changing.In short, I think we need two steps to proceed:
For more detail on the issues encountered in the first exploration, see this comment and screengrab: #48115 (comment)
I'll add the
Needs Designlabel.ndiego commentedon Jun 26, 2023
Given that WordPress 6.3 Beta 1 is tomorrow and there has been no action on this issue, I am going to remove it from the 6.3 Project Board.
jasmussen commentedon Aug 10, 2026
Good issue.
There's a genuine technical questions on where in the matrix we are able to show the contrast checker, i.e. if you are editing your colour palette from Styles > Colors > Palette, you see simply n colour swatches and neither of them have any semantic meaning. We can see in the preview that "Color 1" is the background colour, and "Color 2" is the text colour, naturally those should have sufficient contrast. But without the semantic indication that one swatch has to another, I suspect it will be difficult to show anything in the Color section at all. If a dev has ideas here, I defer to you, but absent any magic we can make happen, what we could do is show a default notice (not dismissible), above or below the palette, something like:
In Styles > Typography, however, it seems like it should be possible to show a contrast checker. E.g. in Typography > Text you see this:
Absent implementation nuance, we could show the contrast checker in the colour flyout (as it exists in the post editor).
Let me know if this resonates.