Skip to content

Instantly share code, notes, and snippets.

@mpriour
Last active January 15, 2022 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpriour/eda8b6767250d41f5e4dc4c249518957 to your computer and use it in GitHub Desktop.
Save mpriour/eda8b6767250d41f5e4dc4c249518957 to your computer and use it in GitHub Desktop.

High contrast accessibility audit for calcite-components

Background

High contrast mode is a special rendering mode on Windows that applies forced colors and simplifies visual elements throughout the entire platform. This mode is an accessibility feature of Windows and used by people with low vision or visual acuity issues. High contrast mode severally changes the way that websites are rendered on all Windows browsers.

References

  1. Enabling high contrast and customizing it (Windows 10 & 11)
  2. Styling Edge for Windows high contrast mode
  3. forced-colors media query (Modern browser support)
  4. -ms-high-contrast media query (IE11 and Legacy Edge support)
  5. forced-colors W3C standards

Baseline rendering of native elements and system colors

Default HC Chromium HC Firefox
baseline-default baseline-hc-chr baseline-hc-ff

Rendering specifics

Chromium-based browsers (Edge and Chrome) and Firefox both respect the forced color and style adjustments of Windows in high contrast mode. Both browsers types use the system colors rather than user specified colors for most elements. The deprecated -ms-high-contrast query still works on Edge, but is expected to be removed "soon". The system colors names and specification is often seen as deprecated as well, but that is the recommended way to specify a color and have it work in high contrast mode. Canvas and CanvasText are meant to replace Window and WindowText and are currently supported in both browser types on Windows. Other than that difference the MDN article on -ms-high-contrast linked above has the other system color names that one can use.

While both browser types render high contrast, there are some obvious differences between the browsers. The most obvious difference is in rendering SVGs with a fill of currentColor. Chromium on Windows has a specific user-agent style for SVG that sets forced-color-adjust: none. This allows one to easily set the color on an SVG in those browsers. However, there is no guaranty that the SVG will have appropriate contrast or even be visible. On Firefox, SVG's currentColor is forced to the WindowText/CanvasText color. This ensures that the icon is visible, but eliminates any color information that the SVG is expected to convey. Another, less obvious difference is that Chromium also sets the value of the prefers-color-scheme in high contrast mode depending on the Window/Canvas color used by the high contrast theme. High contrast themes with backgrounds below a certain luminosity get prefers-color-scheme: dark while background values above that threshold get prefers-color-scheme: light set, regardless of other system preferences. This is not the case in Firefox, which follows the system preference and defaults to prefers-color-scheme: light regardless of the actual theme colors. Because of the way that Firefox overwrites SVG currentColor along with the other rendering changes, the value of prefers-color-scheme has little impact on what the user sees. In Chromium, the primary difference is also in SVG's. Since they maintain the CSS specified color for currentColor, if there are different color values depending on the prefers-color-scheme value then they are seen by the user.

Known issues

The most notable changes with high contrast mode are that box-shadow and background-color compute to none. This means that any component attempting to show state or other information using either of these properties will not show properly if at all. An obvious example of this is the calcite-switch component. It provides no obvious information about its checked state in high contrast. The difference in the way that SVG's are rendered causes issues with the calcite-checkbox component on Firefox and the "neutral" colored buttons with symbols on Chromium browsers.

Comparison Table

Component Default HC Chromium HC Firefox Notes
Checkbox checkbox-default checkbox-hc-chr checkbox-hc-ff FF has trouble with current implementation, but Chromium renders acceptably
Switch switch-default switch-hc Firefox same as Chromium The switched or checked state is not visible in High Contrast browsers
Input - text inputs-text-default inputs-text-hc-chr inputs-text-hc-ff FF renders native input placeholders significantly differently than Chromium
Input - numeric inputs-numeric-default inputs-numeric-hc-chr inputs-numeric-hc-ff Numeric inputs look useable on both high contrast browsers
Inputs - misc inputs-misc-default inputs-misc-hc-chr inputs-misc-hc-ff All of these native input types look useable in high contrast browsers
Input - states inputs-states-default inputs-states-hc-chr inputs-states-hc-ff FF renders disabled inputs strangely but that is its "native" way
Inputs - messages inputs-messages-default inputs-messages-hc-chr inputs-messages-hc-ff The forced color matching of SVG to text color in FF makes it so that there is very little inherent contrast
Inputs - error state inputs-errors-default inputs-errors-hc-chr inputs-errors-hc-ff The lack of a border and border color in high contrast mode makes it hard to see any difference in the field itself
Accordion - basic accordion-basic-default accordion-basic-hc-chr accordion-basic-hc-ff Icon contrast is far too low in Chromium and doesn't meet contrast requirements
Accordion - minimal accordion-min-default accordion-min-hc-chr accordion-min-hc-ff Extra padding is needed in HC or selection/focus highlight obsurces the text
Accordion - transparent accordion-trans-default accordion-trans-hc-chr accordion-trans-hc-ff Other than icon contrast, this version looks good
Action - general action-general-default action-general-hc-chr action-general-hc-ff * Active dot is missing
* No border or distinction of element from page
* Chromium icons are mostly invisible
Action Bar action-bar-default action-bar-hc-chr action-bar-hc-ff * Need a way to distinguish between the bar and the background or other elements
* Icon contrast is too low on Chromium
* Tooltip looks good
Alerts alerts-default alerts-hc-chr alerts-hc-ff No link indicator of any kind in HC. Lack of color in FF means it is impossible to tell the difference between warning and danger
Avatar avatar-default avatar-hc-chr avatar-hc-ff No colored backgrounds. No outline or border to distinguish from page elements
Buttons - solid buttons-solid-default buttons-solid-hc-chr buttons-solid-hc-ff HC Buttons (solid, outline & clear all the same)

No color difference between buttons
Chromium neutral buttons' icons are invisible
Buttons - transparent buttons-trans-default buttons-trans-hc-chr buttons-trans-hc-ff Transparent button colors work in Chromium, but neutral icons are invisible

FF transparent buttons are all the same color
Chips chips-default chips-hc-chr chips-hc-ff FF is fairly functional but is all the same color

Chromium's issues are all related SVG rendering and contrast
Colorpicker colorpicker-default colorpicker-hc-chr colorpicker-hc-ff There are padding issues in the RGB inputs

The color format selector seems to show the wrong one selected

The colorpicker itself looks good
Combobox combobox-default combobox-hc-chr combobox-hc-ff ~
Datepicker datepicker-default datepicker-hc-chr datepicker-hc-ff ~
Dropdown dropdown-default dropdown-hc-chr dropdown-hc-ff ~
Fab fab-default fab-hc-chr fab-hc-ff ~
Icons icons-default icons-hc-chr icons-hc-ff ~
Inline Edit inline-edit-default inline-edit-hc-chr inline-edit-hc-ff ~
Label label-default label-hc-chr label-hc-ff ~
Link link-default link-hc-chr link-hc-ff ~
List list-default list-hc-chr list-hc-ff ~
Loader loader-default loader-hc-chr FF same as Chromium, but crashed the browser everytime ~
Modal modal-default modal-hc-chr modal-hc-ff ~
Notice notice-default notice-hc-chr notice-hc-ff ~
Pagination pagination-default pagination-hc-chr pagination-hc-ff ~
Picklist picklist-deafult picklist-hc-chr picklist-hc-ff ~
Popover popover-default popover-hc-chr popover-hc-ff ~
Progress progress-default progress-hc-chr progress-hc-ff ~
Radio button radio-button-default radio-button-hc-chr radio-button-hc-ff ~
Radio group radio-group-default radio-group-hc-chr radio-group-hc-ff ~
Rating - active rating-active-default rating-active-hc-chr rating-active-hc-ff ~
Rating - read only rating-readonly-default rating-readonly-hc-chr rating-readonly-hc-ff ~
Rating - disabled rating-disabled-default rating-disabled-hc-chr rating-disabled-hc-ff ~
Scrim scrim-default scrim-hc-chr scrim-hc-ff ~
Slider - line slider-line-default slider-line-hc-chr slider-line-hc-ff ~
Slider - histogram slider-histogram-default slider-histogram-hc-chr slider-histogram-hc-ff ~
Sortable sortable-default sortable-hc-chr sortable-hc-ff ~
Stepper stepper-default stepper-hc-chr stepper-hc-ff ~
Tabs - normal tabs-normal-default tabs-normal-hc-chr tabs-normal-hc-ff ~
Tabs - bordered tabs-bordered-default tabs-bordered-hc-chr tabs-bordered-hc-ff ~
Tile - basic tile-basic-default tile-basic-hc-chr tile-basic-hc-ff ~
Tile - input tile-input-default tile-input-hc-chr tile-input-hc-ff ~
Time picker time-picker-default time-picker-hc-chr time-picker-hc-ff ~
Tooltip tooltip-default tooltip-hc-chr tooltip-hc-ff ~
Tree tree-default tree-hc-chr tree-hc-ff ~
Value list value-list-default value-list-hc-chr value-list-hc-ff ~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment