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

Insufficient contrast on borders #38480

Open
3 tasks done
xi opened this issue Apr 19, 2023 · 6 comments
Open
3 tasks done

Insufficient contrast on borders #38480

xi opened this issue Apr 19, 2023 · 6 comments

Comments

@xi
Copy link
Contributor

xi commented Apr 19, 2023

Prerequisites

Describe the issue

WCAG 2.1 requires a contrast of 3:1 for non-text content. Many elements, e.g. form inputs or checkboxes, mostly consist of borders, at least in some of their states. It is therefore important that the border color has sufficient contrast to the background.

#888888 would have sufficient contrast to white. Bootstrap 5.2 uses #ced4da, which only has a contrast of 1.49 to white. Bootstrap 5.3 takes this even further by using #dee2e6 which only has a contrast of 1.3 to white.

I do not have any vision impairments that I know of, but to me these borders are practically invisible (depending on the lighting conditions). I strongly recommend to revert at least to the level of Bootstrap 5.2.

Bootstrap 5.3 introduces variables for the border color, so a workaround would be to set --bs-border-color: #888888.

Reduced test cases

#888888
Bootstrap 5.2.3
Bootstrap 5.3.0-alpha3

What operating system(s) are you seeing the problem on?

Linux

What browser(s) are you seeing the problem on?

Firefox

What version of Bootstrap are you using?

5.3.0-alpha3

@raghav1030
Copy link

is the issue still open ? if so I would very much like to contribute to it?

@ChellyAhmed
Copy link
Contributor

Hello,
Thank you @xi for opening this issue. I also think it is relevant to consider the contrast ratio for the border colors. I used Adobe Color tool (https://color.adobe.com/create/color-contrast-analyzer) for double-checking the contrast. As you mentioned a 1.3:1 to white is not recommended. The lightest color to achieve a ratio of 3.01 : 1 that was suggested by the same tool would be #929598. But I am not sure about which colors we are allowed to use in Bootstrap in case we change the color. Even if we do so, will this mean that we need to update the colors of other elements?

@xi
Copy link
Contributor Author

xi commented Apr 24, 2023

Reacting to #38489 (comment):

Let's keep the PRs at bay for now and discuss any potential changes in the issue. I could see us darkening things a little, but this is too much

I think this regression happened in fc3f4b67:

  • $input-border-color was changed from $gray-400 to var(--border-color) which defaults to $gray-300
  • the color in $form-check-input-border was changed from rgba($black, .25) also to var(--#{$prefix}border-color)

I see two options to fix this:

  • Add a new CSS variable --input-border-color and set it to $gray-400
  • Change --border-color to $gray-400

@mdo which option do you prefer?

Btw, I also checked the contrast for dark mode (#495057 on #212529) and it fares much better: 1.88 is still too low, but much better than the contrasts in light mode.

@ChellyAhmed
Copy link
Contributor

Hello @xi
Thank you for mentioning that the colors changed from Bootstrap 5.2 to 5.3 resulting in a non-recommended contrast ratio.
But I think it is relevant to check why the colors were changed in the first place so we know if changing color is allowed, and the side effects of such a decision. Do you have any input about that?

@RobineSavert
Copy link

Please a fix for this, as the checkboxes are now almost not visible in light mode

@jprante
Copy link

jprante commented Mar 28, 2024

Please, a quick fix is needed. Light mode is almost unusable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To do
7 participants