[accessibility] Improve High Contrast Mode styles for some components#48271
[accessibility] Improve High Contrast Mode styles for some components#48271silviuaavram wants to merge 25 commits intomui:masterfrom
Conversation
Netlify deploy previewhttps://deploy-preview-48271--material-ui.netlify.app/ Bundle size report
|
15b8229 to
340fbb3
Compare
Bundle size
Deploy previewhttps://deploy-preview-48271--material-ui.netlify.app/ Check out the code infra dashboard for more information about this PR. |
340fbb3 to
96a4cba
Compare
There was a problem hiding this comment.
Pull request overview
Improves Windows High Contrast Mode (@media (forced-colors: active)) styling across multiple Material UI components to make selected/disabled/error states more distinguishable, addressing #13174.
Changes:
- Add forced-colors-specific colors/borders for selected and disabled states (e.g., ToggleButton, MenuItem, Autocomplete options, selection controls).
- Improve forced-colors rendering for form inputs (placeholder opacity, disabled/error underline/outline contrast).
- Update a few docs demos to better reflect theme vars usage and forced-colors behavior.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/mui-material/src/ToggleButton/ToggleButton.js | Adds forced-colors selected/hover styling using system colors. |
| packages/mui-material/src/Switch/Switch.js | Adds disabled forced-colors borders for track/thumb. |
| packages/mui-material/src/Slider/Slider.js | Adds borders and disabled forced-colors border color for track/thumb. |
| packages/mui-material/src/Radio/Radio.js | Tweaks disabled color for forced-colors. |
| packages/mui-material/src/OutlinedInput/OutlinedInput.js | Adjusts error/disabled outline and placeholder/disabled text in forced-colors. |
| packages/mui-material/src/NativeSelect/NativeSelectInput.js | Improves disabled icon visibility in forced-colors. |
| packages/mui-material/src/MenuItem/MenuItem.js | Improves selected/hover selected visibility in forced-colors. |
| packages/mui-material/src/Input/Input.js | Improves error/disabled underline and placeholder visibility in forced-colors. |
| packages/mui-material/src/FormLabel/FormLabel.js | Improves error/disabled label text in forced-colors. |
| packages/mui-material/src/FormHelperText/FormHelperText.js | Improves error/disabled helper text in forced-colors. |
| packages/mui-material/src/FormControlLabel/FormControlLabel.js | Improves disabled label text in forced-colors. |
| packages/mui-material/src/FilledInput/FilledInput.js | Improves error/disabled underline and placeholder visibility in forced-colors. |
| packages/mui-material/src/Checkbox/Checkbox.js | Tweaks disabled color for forced-colors. |
| packages/mui-material/src/Autocomplete/Autocomplete.js | Improves selected/disabled option visibility in forced-colors. |
| docs/data/material/components/rating/RadioGroupRating.tsx | Uses `(theme.vars |
| docs/data/material/components/rating/RadioGroupRating.js | Uses `(theme.vars |
| docs/data/material/components/radio-buttons/ErrorRadios.tsx | Simplifies change handler typing; modifies helper text behavior. |
| docs/data/material/components/radio-buttons/ErrorRadios.js | Modifies helper text behavior on change. |
| docs/data/material/components/radio-buttons/CustomizedRadios.tsx | Adds forced-colors outlines for custom radio styling. |
| docs/data/material/components/radio-buttons/CustomizedRadios.js | Adds forced-colors outlines for custom radio styling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3e17293 to
fda4e72
Compare
There was a problem hiding this comment.
I agree with the improvement but have you consider a different path like providing it as a theme enhancement and let users choose to include to their app?
The benefits:
- no bundle size changes, win-win for users
- user owns the code, adjust the colors they want
- less maintenance burden on our side
The usage is something like:
const highContrastEnhancement = … // copy from our source.
createTheme({ … }, highContrastEnhancement)cc @mnajdova
|
Could we assign a bundle size/performance budget to this, and work under it? At the end of the day, is this something people want? I don't recall seeing user traction, so probably something we should stick to a best effort (improve what we can without harming the majority of the developers and end-users). |
|
Agree on this needing to be an opt in - likely a theme on top of Material UI like @siriwatknp suggested. With this:
|
Fixes #13174
Improves support for Dark High Contrast for our
Inputscomponents. We should continue this effort with:InputsFor disabled, use
GrayTextfor border, placeholder and text.For error, use
markfor border and text.For selected, use
Highlightfor border,HighlightTextfor text, andnoneforforcedColorAdjust.When both error and disabled are true, disabled wins, since there's no point in showing an error control if we can't do anything about it.
Some docs examples needed style changes since they did not support high contrast.
Slider received transparent border so it will become visible in HC.