Skip to content

[accessibility] Improve High Contrast Mode styles for some components#48271

Closed
silviuaavram wants to merge 25 commits intomui:masterfrom
silviuaavram:feat/high-contrast-components
Closed

[accessibility] Improve High Contrast Mode styles for some components#48271
silviuaavram wants to merge 25 commits intomui:masterfrom
silviuaavram:feat/high-contrast-components

Conversation

@silviuaavram
Copy link
Copy Markdown
Member

@silviuaavram silviuaavram commented Apr 13, 2026

Fixes #13174

Improves support for Dark High Contrast for our Inputs components. We should continue this effort with:

  • Light High Contrast
  • Focus / Hover improved support in both Dark and Light High Contrast
  • The rest of the components, not just Inputs

For disabled, use GrayText for border, placeholder and text.
For error, use mark for border and text.
For selected, use Highlight for border, HighlightText for text, and none for forcedColorAdjust.
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.

Use Case Before After
Disabled Checkbox Screenshot 2026-04-14 at 15 53 03 Screenshot 2026-04-14 at 15 53 09
Disabled Radio Screenshot 2026-04-14 at 15 53 57 Screenshot 2026-04-14 at 15 53 53
Input Placeholder Screenshot 2026-04-14 at 15 57 49 Screenshot 2026-04-14 at 15 57 54
Disabled Inputs Screenshot 2026-04-15 at 21 02 31 Screenshot 2026-04-15 at 21 02 39
Error Inputs Screenshot 2026-04-15 at 21 03 59 Screenshot 2026-04-15 at 21 04 02
Autocomplete Disabled Options Screenshot 2026-04-14 at 16 01 44 Screenshot 2026-04-14 at 16 01 28
Rating Radio Example (Dark Mode + High Contrast) Screenshot 2026-04-15 at 20 45 40Screenshot 2026-04-15 at 20 45 33 Screenshot 2026-04-15 at 20 45 20Screenshot 2026-04-15 at 20 45 15
Customized Radio Example Screenshot 2026-04-15 at 20 49 00 Screenshot 2026-04-15 at 20 49 04
Error Radio Example Screenshot 2026-04-15 at 20 50 15 Screenshot 2026-04-15 at 20 50 07
Disabled Select Screenshot 2026-04-15 at 21 11 27 Screenshot 2026-04-15 at 21 10 45
Selected Menu Item (works also with Select and Autocomplete) Screenshot 2026-04-16 at 16 01 07 image
Slider Screenshot 2026-04-16 at 16 13 46 Screenshot 2026-04-16 at 16 14 43
Disabled Slider Screenshot 2026-04-16 at 16 13 46 image
Toggle Button Selected Screenshot 2026-04-16 at 16 45 42 Screenshot 2026-04-16 at 16 45 52
Toggle Button Selected + Hovered Screenshot 2026-04-16 at 16 46 02 Screenshot 2026-04-16 at 16 45 57

@mui-bot
Copy link
Copy Markdown

mui-bot commented Apr 13, 2026

Netlify deploy preview

https://deploy-preview-48271--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 🔺+1.01KB(+0.20%) 🔺+162B(+0.11%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 15b8229

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Apr 13, 2026
@silviuaavram silviuaavram force-pushed the feat/high-contrast-components branch from 15b8229 to 340fbb3 Compare April 14, 2026 12:47
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Apr 14, 2026
@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard bot commented Apr 14, 2026

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+2.57KB(+0.51%) 🔺+400B(+0.27%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Deploy preview

https://deploy-preview-48271--material-ui.netlify.app/


Check out the code infra dashboard for more information about this PR.

@silviuaavram silviuaavram force-pushed the feat/high-contrast-components branch from 340fbb3 to 96a4cba Compare April 15, 2026 12:29
Comment thread docs/data/material/components/radio-buttons/CustomizedRadios.js
Comment thread docs/data/material/components/radio-buttons/ErrorRadios.js
Comment thread docs/data/material/components/rating/RadioGroupRating.js
@silviuaavram silviuaavram marked this pull request as ready for review April 17, 2026 07:20
Copilot AI review requested due to automatic review settings April 17, 2026 07:20
@silviuaavram silviuaavram self-assigned this Apr 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/mui-material/src/Slider/Slider.js
Comment thread docs/data/material/components/radio-buttons/ErrorRadios.tsx
Comment thread docs/data/material/components/radio-buttons/ErrorRadios.js
@silviuaavram silviuaavram force-pushed the feat/high-contrast-components branch 2 times, most recently from 3e17293 to fda4e72 Compare April 17, 2026 08:15
Copy link
Copy Markdown
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@oliviertassinari
Copy link
Copy Markdown
Member

oliviertassinari commented Apr 17, 2026

Could we assign a bundle size/performance budget to this, and work under it?
To also look at the customization DX implications.

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).

@mnajdova
Copy link
Copy Markdown
Member

Agree on this needing to be an opt in - likely a theme on top of Material UI like @siriwatknp suggested. With this:

  • it won't mess up any overrides that teams may have already done on the topic
  • it wouldn't add any bandle size by default for teams not needing this
  • it would make customizing it a bit better - by providing the colors we most commonly use for this mode of the components
  • we could promote it as a new feature - this is a bonus

@silviuaavram
Copy link
Copy Markdown
Member Author

Splitting the changes into #48319 and #48320. Closing the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Accessibility] Some of the components are not visible or rendered properly in Windows High Contrast Mode

6 participants