fix(Alert): add high contrast mode border via enhanceHighContrast#48731
Open
kartikjsonawane wants to merge 2 commits into
Open
fix(Alert): add high contrast mode border via enhanceHighContrast#48731kartikjsonawane wants to merge 2 commits into
kartikjsonawane wants to merge 2 commits into
Conversation
Deploy previewhttps://deploy-preview-48731--material-ui.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
mj12albert
reviewed
Jun 25, 2026
| // in HCM backgrounds are overridden, so restore contrast via border. | ||
| [`&.${alertClasses.filled}`]: { | ||
| [HCM]: { | ||
| forcedColorAdjust: 'none', |
Member
There was a problem hiding this comment.
Is this enough? filled alert styles also define color/backgroundColor
Author
|
Yes I reviewd the code. Good catch, thanks! You're right forcedColorAdjust: 'none' on its own isn't really enough since the filled alert's severity colors (like orange for warning) could still lack contrast in HCM. I've pushed an update that also explicitly sets color and backgroundColor using the system color tokens, similar to how MuiToggleButton handles it. The outline stays to keep the alert boundary visible. |
c146629 to
e09fad7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #48681 (partial — Alert component)
What's changed
Added MuiAlert to enhanceHighContrast.ts so that Alert components get a visible border when Windows High Contrast Mode is active.
All variants (standard, outlined) get a 1px solid ButtonBorder outline
The filled variant gets a 2px solid ButtonBorder outline with forcedColorAdjust: none to preserve the extra visual weight, since filled alerts rely on background color to convey severity — which HCM overrides
Why
In HCM, background colors and box shadows are stripped by the OS, making Alert components invisible against the canvas. Adding a border restores the visual boundary so users can tell an alert region is present.
Testing
To verify, enable Windows High Contrast Mode (Settings → Accessibility → Contrast themes) and check the MUI Alert demo in a browser with prefers-contrast: forced or forced-colors: active.
Notes
This only addresses Alert. Other components mentioned in #48681 (Tabs, Paper, Button) are left for follow-up PRs to keep changes reviewable.