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

[material-ui][Switch] Failing on color contrast checks #39134

Open
2 tasks done
chris-gds opened this issue Sep 24, 2023 · 6 comments
Open
2 tasks done

[material-ui][Switch] Failing on color contrast checks #39134

chris-gds opened this issue Sep 24, 2023 · 6 comments
Assignees
Labels
accessibility a11y breaking change component: switch This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material

Comments

@chris-gds
Copy link

chris-gds commented Sep 24, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example:
https://mui.com/material-ui/react-switch/

Steps:

  1. Visit page.
  2. Check colour contrast.

Current behavior 😯

All of the switches fail colour contrast checks in some way.

Switch demo Switch demo Switch demo Switch demo
switch-4 on material-ui, highlighting poor contrast switch-3 on material-ui, highlighting poor contrast switch-2 on material-ui, highlighting poor contrast switch-1 on material-ui, highlighting poor contrast

Expected behavior 🤔

I would expect all of the switch Designs to pass colour contrast AA checks.

Context 🔦

Users that blind or visually impaired impacted - switches do not have the correct contrast.

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@chris-gds chris-gds added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 24, 2023
@chris-gds chris-gds changed the title Switch path fails colour contrast checks WCAG 1.4.3 Switches fail colour contrast checks WCAG 1.4.3 Sep 24, 2023
@danilo-leal danilo-leal changed the title Switches fail colour contrast checks WCAG 1.4.3 [material-ui][Switch] Failing on color contrast checks Sep 24, 2023
@danilo-leal danilo-leal added accessibility a11y component: switch This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Sep 24, 2023
@juperameza
Copy link

Hi, is this issue being work on ??
I'll be happy to contribute.
I checked on my own computer and it passes the guidelines but I'm using dark mode. I can check for some middle ground where it passes on dark and light mode

@mj12albert
Copy link
Member

We'd have to modify the styles in the component itself as we don't want to add additional styles to Material UI demos

@danilo-leal Is that ok (not really a breaking change?) if the adjustments are small?

@mj12albert
Copy link
Member

@juperameza Thanks for your interest, let's wait for Danilo to confirm how to do this one first ~

I can check for some middle ground where it passes on dark and light mode

BTW it may not be necessary to find middle ground, it's ok to use different values for each color mode if overall it's better, e.g. here 😬

@mj12albert mj12albert assigned danilo-leal and unassigned mj12albert Oct 9, 2023
@mj12albert mj12albert removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 9, 2023
@danilo-leal danilo-leal assigned zanivan and unassigned danilo-leal Nov 9, 2023
@zanivan
Copy link
Contributor

zanivan commented Nov 9, 2023

Hey there! Allow me to chime in for a bit 😉

Is that ok (not really a breaking change?) if the adjustments are small?

IMO, as long as we keep using the current Material UI tokens or styles for tiny adjustments, it shouldn’t be a breaking change.


About the issue, though, I wonder if this is really necessary. By the WCAG guidelines, the visual of components should have an AA contrast ratio, it means at least 3:1 against adjacent colors.

However, in this component we don't rely only on color to distinguish the states, since the thumb surpasses the track, and we also have a box-shadow and some micro interactions.

That said, I think the default switch has room for improvement. Maybe working on the box-shadow a bit, so it would present a slight contour on the whole thumb? Regardless, I'm open for suggestions and tiny improvements @juperameza

@chris-gds
Copy link
Author

chris-gds commented Nov 19, 2023

About the issue, though, I wonder if this is really necessary.

👋🏼 Can you expand a little?

By the WCAG guidelines, the visual of components should have an AA contrast ratio, it means at least 3:1 against adjacent colors.

From a WCAG POV, I would imagine this does fail, the colours do not have enough contrast. Within Chrome, you can emulate vision deficiencies to give a clearer insight to what a user might experience.

You'll notice if you emulate "reduce contrast", it becomes very hard to see. Should contrast checks pass this would improve. Users with retinal disorders such as age-related macular degeneration (ARMD), amblyopia, lens abnormalities, such as cataract might experience the switch in this way.

reduced-contrast emulation on chrome for material-ui switch

Also if you remove colour, the switch state is a little unclear. Which switch is on or off? Which switch is disabled?
However this is different topic for a different PR.
no-colour-emulation on chrome for material-ui switch

Ideally darkening the colours until they pass AA is really quick fix to improve accessibility.

@zanivan
Copy link
Contributor

zanivan commented Nov 20, 2023

Nice points @chris-gds, and it indeed makes a lot of sense. However, to achieve this level of contrast, I believe it would be a breaking change, since we would have to increase and change colors too much—besides, it'd be very distant from MD default.
Then, I'll do as in #39809 and mark as a breaking change to review and come back to it before the next major.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y breaking change component: switch This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

No branches or pull requests

7 participants