Skip to content

Commit 15069ea

Browse files
[docs] Fix light/dark mode blink on pickers overview (#18002)
1 parent f9397b4 commit 15069ea

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/src/modules/components/overview/pickers/MainDemo.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ const components: Components<Theme> = {
6565
},
6666
};
6767

68+
// Use CSS variables to avoid first load light/dark blink.
69+
const darkThemeManagement = {
70+
colorSchemes: { light: true, dark: true },
71+
cssVariables: {
72+
colorSchemeSelector: 'data-mui-color-scheme',
73+
},
74+
};
75+
6876
export default function MainDemo() {
6977
const brandingTheme = useTheme();
7078
const isMobile = useMediaQuery(brandingTheme.breakpoints.down('sm'));
@@ -77,7 +85,7 @@ export default function MainDemo() {
7785
setShowCustomTheme((prev) => !prev);
7886
};
7987

80-
const theme = createTheme({ palette: { mode: brandingTheme.palette.mode } });
88+
const theme = createTheme(darkThemeManagement, { palette: { mode: brandingTheme.palette.mode } });
8189
const customTheme = createTheme(brandingTheme, {
8290
components,
8391
shape: { borderRadius: 8 },

0 commit comments

Comments
 (0)