-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Review contrast for common colour schemes to improve a11y #5497
Comments
Spent a bit of time on this.. basically all of our current standard colour combinations score pretty poorly on contrast: Keeping all the existing backgrounds as they are but switching the text colour from white to black would give greater contrast in all cases and get us up to at least WCAG AA for small (below 18pt) fonts. If we did that on our badges that would take us from to something like which does have more contrast but does seem to 'pop' slightly less. I wonder if tweaking the drop-shadow a bit could improve that? (not really a design person). |
it would be nice to at least have an option to toggle. so you could preserve the existing behavior, but people could opt-in for WCAG AA compliance if they wanted. alternatively, though not as convenient, would be an additional option to set the text color directly. |
Hi, I’m a designer at GitHub and npm. We’re currently fixing accessibility issues across the npmjs.com site. One problem that was raised in a recent audit1 was the contrast ratio of shields.io badges on package readmes2. We pull these from GitHub readmes and obviously have no control over their styling. I’d love to offer design help to find a solution to the contrast issues mentioned above in the thread. We have some precedent for solving for this on GitHub issues labels3, and it looks like this may be true of the shields users specify a custom colour for as well. If you’re open to it, I can do some visual explorations that might be useful in moving toward (or ruling out) various directions. Footnotes
|
That would be fabulous @dylanatsmith, thanks so much 🙏 ❤️ |
it's worth noting that WCAG 3 will use a new system APCA (Advanced Perceptual Contrast Algorithm). as an aside, I ended up creating a11y-badges for exactly this reason. I have yet to update it to use APCA though. |
I also think that it should be addressed. The colour and text should by default be accessible and friendlier without any configuration from the party who using it. As an example, I use a third party to for my end-to-end testing who return a badge. Should I write to every third party that I use to update the configuration, which will only go to their backlog? It might seem extreme, but all element on a page should be accessible, not only some. |
Maybe GitHub's own design system could serve as an inspiration for badge colors? |
I''ve stumbled upon this issue while trying figure out if text color could be changed. In my example the background color is Demo: . This fails Web Content Accessibility Guidelines (WCAG): contrast checker (screenshot).
@chris48s, here's a suggestion for WCAG compliance. To choose a compliant foreground color, the contrast ratio of background color with white and black foreground could be calculated. Then choose the color with greater contrast. WCAG website gives formulas for how to calculate the contrast ratio. |
Coming over from #9890: thinking about how the white foreground text in typical badges has a slight background shadow between it and the background (#5497 (comment)). That shadow improves its readability a bit. But it's only the pixels below the text. So I think wouldn't be counted as improving contrast unless it surrounds a majority of the pixels around the letters. Proposal: How about the following somewhat-dynamic contrast system...
...along with adjusting all preset colors so that they'd be accessible in the new system with white foreground text? Examples: The following table shows what that'd look like using myndex.com/APCA to calculate APCA contrast.
I'd be happy to send PRs for this work! |
Thanks for the suggestions @JoshuaKGoldberg Sorry it has taken a few days to reply to this, but I have been thinking about it. Broadly speaking:
There's a number of other suggestions here about providing extra configuration options and automatic contrast detection. I'm not dismissing them out of hand, but I think if we can start by adjusting the 9 standard named/semantic colours we use on every (non-custom) badge, that would improve accessability in like 99% of cases. So I think that is where I'd like to constrain the scope first. Seems like we can do a lot of good there as a first step without introducing a lot of complexity. I have a few follow up questions:
I have made more more notes beyond that, but if we could just focus on those 3 points to start with, that would be great. |
It's the threshold for "body text okay" per APCA (myndex.com/APCA). "This level may be used with non-body text with a font no smaller than 15px/400."
It would be compliant for the current WCAG 3 draft that uses APCA1.
You got it! The current text shadow is a 30% opacity
At that point, I think it's safe to compute background colors by:
Here's a table showing those updates: I'd personally probably go with a Footnotes |
This seems to have fizzled out a bit, but I'd quite like to not lose momentum on this. Feels like we are fairly close to a solution. I think we can find a workable drop shadow, even if the exact value is TBC. There's a couple more things I do want to bring up.
|
This all sounds good to me!
👍 I quite like that, but was nervous to propose a change that touched so much of the visual state. Sounds great 😄.
👍 I'd be happy to help with a follow-up too. It strikes me as likely that shipping a first round of them will inevitably cause some users to rush out of the shadows and make noise about the changes. Fast follows are probably going to be asked for.
TIL! Very interesting. Some of the lighter CSS colors show up better than others right now. Proposal: for now, let's only add this new shadow in existing cases where text would be switched to black? I think
👍 how does Aside: I threw together a script to generate a table of comparisons for any particular svg type: https://github.com/JoshuaKGoldberg/badges-shields-shadow-reference. |
If you think about
Does |
Oh! Fascinating, I hadn't thought of that. I'd thought |
📋 Description
Refs #5467
Some of our standard colour schemes score quite poorly on contrast for accessibility and could be improved. For example
We should review our most commonly used styles from this perspective. We probably can't rely on only brightness to get amazing contrast on every bespoke colour, but we can probably look at 'presets' or a package like color-contrast-checker to ensure all of these have a decent accessibility score.
The 'inactive' style also performs quite badly:
The text was updated successfully, but these errors were encountered: