bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Windows High Contrast Mode / forced color adaptations

Open patrickhlauke opened this issue 3 years ago • 6 comments

Proposal

Adding a few surgical, very specific general styles to Bootstrap using the (forced-colors) media query, to make sure that some of our components that aren't properly discernible in Windows High Contrast Mode stand a slightly better chance at having at least minimal styles applied even in WHCM.

Motivation and context

Splitting the idea out of https://github.com/twbs/bootstrap/pull/29490

A lot of the standard Bootstrap styles rely on background colours, borders and shadows (e.g. to make buttons/pills/etc look "button-like"). These styles usually get completely overridden by Windows High Contrast Mode (WHCM), which explicitly ignores things like background and forces specific user-defined colours for things.

Until recently, there was no clean standardised way of approaching this issue (even with proprietary things like -ms-high-contrast - see https://www.tpgi.com/windows-high-contrast-mode-the-limited-utility-of-ms-high-contrast/)

However, the relatively new (forced-colors) media query offers a relatively stable way of approaching this issue now, adding very targeted adaptations/tweaks for cases where WHCM is enabled.

I have recently been playing with it on a project (not directly using Bootstrap, but the concept is obviously the same) to force an outline (rather than a border, so it doesn't affect element dimensions), a la

@media (forced-colors) {
  button {
    outline: 1px solid LinkText !important;
  }
}

Trying to do further/more intense styling is probably counterproductive (i.e. not doing a whole exercise like dark mode or anything), but just some basics like this would immediately make BS more WHCM-friendly for very little extra effort.

patrickhlauke avatar Mar 03 '22 09:03 patrickhlauke

Hi @patrickhlauke, are you aware of a shared gist or other source that gathers together the forced-color adaptions that aren't yet accepted into upstream Bootstrap? I'm looking at adding them to a Bootstrap 4(.6) project and if one doesn't exist I might create it as it seems generally useful and shareable, rather than project specific.

davidscotson avatar Jun 17 '22 08:06 davidscotson

i don't think there's a single collated list at the moment. would suggest, if you can find the time, going through the docs pages and trying to identify all the different places where currently forced colors/WHCM is not ideal (in terms of borders, outlines, etc not showing up)

patrickhlauke avatar Jun 17 '22 09:06 patrickhlauke

I've started a gist here, I'll try to remember to update it as I test and find issues:

https://gist.github.com/davidscotson/446f5a637715af9d1db832f60640e705

davidscotson avatar Jun 17 '22 16:06 davidscotson

Taking https://getbootstrap.com/docs/5.2/examples/cheatsheet/ for a quick spin in high contrast (Windows 10 WHCM, Chrome):

Forms

Overview

  • checked checkbox, selected radio button, shows no focus indication image

  • switch checkbox input: when not checked, only shows outline border; when focused, shows faint off switch; when checked, has no focus indicator image image image

  • example range totally invisible image

Floating labels

  • floating label doesn't hide placeholder text; when focused, shows awkward focus outline image

Validation

  • "Agree..." checkbox shows no focus indication image

Components

  • Accordion shows no focus indication

image

Alerts

  • No visible X close control, no focus indication for it image

Badge

  • Shows no outline/border image

Carousel

  • Dots look awkward/wrong image

Dropdowns

  • Down arrow looks wrong
  • Focus indication on active dropdown item not shown image

Modal

  • No visible X close control, no focus indication for it image

Navs

  • doesn't show active one image

Navbar

  • First example, logo doesn't show image

Pagination

  • Current active one not shown image

Popovers

  • Arrow looks awkward/wrong image

Progress

  • Bar is totally invisible image

Spinners

  • Completely static circles image

Toasts

  • No visible X close control, no focus indication for it image

Tooltips

  • Arrow looks awkward/wrong image

Other

A few other examples not covered in the cheatsheet:

  • toggle buttons https://getbootstrap.com/docs/5.2/components/buttons/#toggle-states don't visually differentiate active one image

  • checkbox/radio button group https://getbootstrap.com/docs/5.2/components/button-group/#checkbox-and-radio-button-groups don't differentiate checked/unchecked image

  • as already seen in the alert and modal above, close button https://getbootstrap.com/docs/5.2/components/close-button/ doesn't show at all (except for its white variant) image

patrickhlauke avatar Jul 29 '22 23:07 patrickhlauke

Another thing I didn't see in previous comments is the fact that you can't see the checked state of the checkboxes when viewed in certain themes, such as High Contrast White in Windows 10 and Desert High Contrast in Windows 11. You can find an explanation of the issues I found with this control and my proposed solutions in this CodePen: Fixing Accessibility of Bootstrap's Checkbox Styling

Here is a gist of the same, basically: Contrast tweaks for checkbox in Bootstrap

This is easy to miss, because it doesn't show up when checking with darker themes, which is all most people test with.

I'm not sure, but I think I remember there being similar issues with the radio buttons.

robfentress avatar Dec 20 '22 20:12 robfentress