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

[CssBaseline] Remove color-scheme logic if used with CssVarsProvider #34640

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/mui-material/src/CssBaseline/CssBaseline.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export interface CssBaselineProps extends StyledComponentProps<never> {
* Enable `color-scheme` CSS property to use `theme.palette.mode`.
* For more details, check out https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme
* For browser support, check out https://caniuse.com/?search=color-scheme
*
* This flag has no effect if the CssBaseline is wrapped inside [CssVarsProvider](https://mui.com/material-ui/experimental-api/css-theme-variables/usage/#getting-started)
*
* @default false
*/
enableColorScheme?: boolean;
Expand Down
5 changes: 4 additions & 1 deletion packages/mui-material/src/CssBaseline/CssBaseline.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export const html = (theme, enableColorScheme) => ({
boxSizing: 'border-box',
// Fix font resize problem in iOS
WebkitTextSizeAdjust: '100%',
...(enableColorScheme && { colorScheme: theme.palette.mode }),
// enableColorScheme has no effect if wrapped inside CssVarsProvider
// because the `theme.palette.mode` could be different between server and the client.
// Cause the stylesheet to be created twice for server-rendered applications.
...(enableColorScheme && !theme.vars && { colorScheme: theme.palette.mode }),
});

export const body = (theme) => ({
Expand Down