Skip to content

fix(Alert): add high contrast mode border via enhanceHighContrast#48731

Open
kartikjsonawane wants to merge 2 commits into
mui:masterfrom
kartikjsonawane:fix/high-contrast-alert
Open

fix(Alert): add high contrast mode border via enhanceHighContrast#48731
kartikjsonawane wants to merge 2 commits into
mui:masterfrom
kartikjsonawane:fix/high-contrast-alert

Conversation

@kartikjsonawane

@kartikjsonawane kartikjsonawane commented Jun 25, 2026

Copy link
Copy Markdown

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.

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploy preview

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

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+307B(+0.06%) 🔺+59B(+0.04%)
@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


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

// in HCM backgrounds are overridden, so restore contrast via border.
[`&.${alertClasses.filled}`]: {
[HCM]: {
forcedColorAdjust: 'none',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this enough? filled alert styles also define color/backgroundColor

@mj12albert mj12albert requested a review from silviuaavram June 25, 2026 10:06
@mj12albert mj12albert added the scope: alert Changes related to the alert. label Jun 25, 2026
@kartikjsonawane

Copy link
Copy Markdown
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.

@kartikjsonawane kartikjsonawane force-pushed the fix/high-contrast-alert branch from c146629 to e09fad7 Compare June 25, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: alert Changes related to the alert.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants