halfmoonui / halfmoon

Halfmoon is a highly customizable, drop-in Bootstrap replacement. It comes with three built-in core themes, with dark mode support for all themes and components.
https://www.gethalfmoon.com
MIT License
3.04k stars 118 forks source link

Some of the colours used on buttons do not meet Web Content Accessibility Guidelines (WCAG) #27

Open joelamyman opened 4 years ago

joelamyman commented 4 years ago

Issue

Screenshot of the primary button within the Halfmoon UI with a contrast of 3.24, which does not meet Web Content Accessibility Guidelines (WCAG)

The contrast on the .btn-primary, .btn-danger and .btn-link button classes do not meet the required color contrast ratio of 4.5:1, (WCAG 1.4.3 Contrast).

To resolve this issue

Increasing the contrast would solve this issue, happy to recommend some colors or create a pull request with some ammendments.

halfmoonui commented 4 years ago

Hey, thank you for bringing this up. From my point of view, the buttons in Halfmoon are quite readable to the naked eye. Going with the strict rule of 4.5:1 here would make the aesthetics of the framework worse, and in return bring in negligible improvements in readability. Also, this is one of those rules that most websites fail at, including other frameworks:

Bootstrap primary button: bootstrap-primary-button

Bulma primary button: bulma-primary-button

Materialize primary button: materialize-primary-button

Not saying that its okay to follow a bad practice just because it is popular, but I think there is good reason for it. As I mentioned above, if it is readable to the naked eye, following the theoretical guideline often makes the aesthetics worse, which is of course very important in web design. And the trade-off is usually not worth it.

PS Bulma's button is not actually properly readable, and they should probably increase the contrast a little.

EDIT I tried Tailwind's blue-500 as the button background, the contrast ratio got worse. Seems like if you want to make a blue button on the web, you either go with dark blue or don't meet the WCAG guideline. I am willing to solve this issue but dark blue just doesn't look good with Halfmoon's default theme, especially dark mode.

joelamyman commented 4 years ago

Thanks for responding, I understand that you're hesitant to change the current colors because of the following:

In regards to the first point, it is not the case that you can't have both aesthetic appeal and an accessible user interface.

However in terms of prioritisation, I think it's important that the design is as accessible to as many people as possible. While the current contrast may look fine to some people, given the different needs of individuals and different use cases, it may be problematic. Conforming to the web content accessibility guidelines means that it should be as accessible to as many people as possible, yet even then it may not be accessible to everyone! However, allowing as many people to use sites with halfmoon would be a great goal.

I think that even if the primary button color was changed to something like #0074E0, halfmoon would then be meeting the WCAG 2.1 AA requirements without a major change to aesthetics.

Moving onto the second point, I think that it's poor that other frameworks are not accessible by default. Your point about Bulma's primary button is spot on, the contrast for that item is poor and the font-weight: 400 rule does not help this. I see that these frameworks will then say something like, "We're not accessible by default, but you can easily make it accessible". But let's be honest, not many people are going to change those defaults.

Instead, it would be fantastic if there is a framework that says, "By default, with no extra work needed, our components meet WCAG 2.1 AA". I think that would really differentiate a framework from the rest, I think that would be a big selling point. It would then start to go some ways towards helping more sites to become more accessible to all users of the web.

halfmoonui commented 4 years ago

I set the following: --primary-color: #0074E0, and while this fixes the accessibility issues for the primary button, the contrast ratio for links and link buttons goes down in dark mode. I think the built in dark mode creates an extra challenge for making everything look good and also be accessible at the same time. On top of that, I think the darker blue #0074E0 buttons look worse overall (purely in terms of aesthetics).

However, I do agree that you bring up some great points, and striving for better accessibility out of the box is definitely a good goal to have. But perhaps a different approach is needed for a framework like Halfmoon. I have seen that Apple has two sets of colors for their system: light mode and dark mode. On top of that, they have an extra pair with better accessibility: https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/

Perhaps a similar approach would work well here too.

CooperCorona commented 3 years ago

I'd like to echo joelamyman's points and try to address some misconceptions.

I only recently discovered Halfmoon, but I'm excited to use it and see where it goes. But I'd be more excited if it had accessibility "baked in". This would be a huge advantage for Halfmoon, for developers using Halfmoon, and for users of sites developed with Halfmoon.