You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
boxShadow:'none', // remove the box shadow in dark mode
64
66
}),
65
-
})}
67
+
]}
66
68
/>;
67
69
```
68
70
69
71
:::warning
70
-
Do not use `theme.palette.mode` to switch between light and dark styles—this produces an [unwanted flickering effect](/material-ui/customization/dark-mode/#dark-mode-flicker).
Do not use `theme.palette.mode` to switch between light and dark styles—this produces an [unwanted flickering effect](/material-ui/customization/css-theme-variables/configuration/#preventing-ssr-flickering).
81
73
:::
82
74
83
75
## Using theme variables
@@ -94,17 +86,17 @@ This `vars` object mirrors the structure of a serializable theme, with each valu
94
86
}));
95
87
```
96
88
97
-
For **TypeScript**, the typings are not enabled by default.
98
-
Follow the [TypeScript setup](#typescript) to enable the typings.
89
+
For **TypeScript**, the typings are not enabled by default.
90
+
Follow the [TypeScript setup](#typescript) to enable the typings.
99
91
100
-
:::success
101
-
If the components need to render outside of the `CssVarsProvider`, add fallback to the theme object.
92
+
:::success
93
+
If the components need to render outside of the `CssVarsProvider`, add fallback to the theme object.
-**Native CSS**: if you can't access the theme object, for example in a pure CSS file, you can use [`var()`](https://developer.mozilla.org/en-US/docs/Web/CSS/var) directly:
If you need to support system preference and manual selection, check out the [advanced configuration](/material-ui/customization/css-theme-variables/configuration/)
// This allows to use theme.applyStyles() inside template literals
289
+
constStyledButton=styled('button')`
290
+
${theme.applyStyles('dark', `
291
+
background: white;
292
+
`
293
+
)}
294
+
`;
295
+
```
296
+
297
+
When overriding `theme.applyStyles()`, you have complete control over its arguments and return value.
298
+
Please review the [source code](https://github.com/mui/material-ui/blob/HEAD/packages/mui-system/src/createTheme/applyStyles.ts) to understand how the default implementation works before overriding it.
299
+
232
300
### Codemod
233
301
234
302
We provide codemods to migrate your codebase from using `theme.palette.mode` to use `theme.applyStyles()`.
0 commit comments