Files
react-test/test/regressions/fixtures/CssVarsProvider/InjectFirstWithThemeVars.js
how2ice 005cf56baf
Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
init project
2025-12-12 14:26:25 +09:00

42 lines
954 B
JavaScript

import * as React from 'react';
import {
ThemeProvider,
createTheme,
StyledEngineProvider,
useColorScheme,
} from '@mui/material/styles';
import Box from '@mui/material/Box';
const theme = createTheme({
colorSchemes: { dark: true },
cssVariables: { colorSchemeSelector: '.regression-inject-first-%s' },
});
function AutoDark() {
const { setMode } = useColorScheme();
React.useEffect(() => {
setMode('dark');
}, [setMode]);
return null;
}
export default function InjectFirstWithThemeVars() {
return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme} modeStorageKey="regression-inject-first">
<AutoDark />
<Box
sx={{
border: 2,
borderColor: 'divider',
backgroundColor: 'background.default',
width: 100,
height: 100,
m: 1,
}}
/>
</ThemeProvider>
</StyledEngineProvider>
);
}