-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Update CSS theme variables related content (#43130)
- Loading branch information
1 parent
8ab2137
commit 3208bfe
Showing
20 changed files
with
512 additions
and
803 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
Broken links found by `pnpm docs:link-check` that exist: | ||
|
||
- https://mui.com/material-ui/customization/css-theme-variables/configuration/#advanced-configuration | ||
- https://mui.com/material-ui/customization/css-theme-variables/configuration/#changing-variable-prefixes | ||
- https://mui.com/material-ui/customization/theme-components/#creating-new-component-variants | ||
- https://mui.com/material-ui/customization/theme-components/#overrides-based-on-props | ||
- https://mui.com/material-ui/react-grid2/#whats-changed |
69 changes: 69 additions & 0 deletions
69
docs/data/material/customization/css-theme-variables/DisableTransitionOnChange.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import * as React from 'react'; | ||
import { createTheme, ThemeProvider, useColorScheme } from '@mui/material/styles'; | ||
import Stack from '@mui/material/Stack'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import Switch from '@mui/material/Switch'; | ||
import Select from '@mui/material/Select'; | ||
import FormControlLabel from '@mui/material/FormControlLabel'; | ||
|
||
const theme = createTheme({ | ||
cssVariables: { | ||
colorSchemeSelector: '.demo-disable-transition-%s', | ||
}, | ||
colorSchemes: { dark: true }, | ||
}); | ||
|
||
function ModeSwitcher() { | ||
const { mode, setMode } = useColorScheme(); | ||
if (!mode) { | ||
return null; | ||
} | ||
return ( | ||
<Select | ||
value={mode} | ||
onChange={(event) => setMode(event.target.value)} | ||
sx={{ minWidth: 120 }} | ||
> | ||
<MenuItem value="system">System</MenuItem> | ||
<MenuItem value="light">Light</MenuItem> | ||
<MenuItem value="dark">Dark</MenuItem> | ||
</Select> | ||
); | ||
} | ||
|
||
export default function DisableTransitionOnChange() { | ||
const [disableTransition, setDisableTransition] = React.useState(false); | ||
return ( | ||
<ThemeProvider | ||
theme={theme} | ||
disableNestedContext | ||
disableTransitionOnChange={disableTransition} | ||
> | ||
<Stack | ||
sx={{ | ||
width: '100%', | ||
borderRadius: '4px', | ||
p: 2, | ||
gap: 2, | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
bgcolor: 'background.default', | ||
color: 'text.primary', | ||
transition: '1s', | ||
}} | ||
> | ||
<ModeSwitcher /> | ||
<FormControlLabel | ||
control={ | ||
<Switch | ||
checked={disableTransition} | ||
onChange={(event) => setDisableTransition(event.target.checked)} | ||
/> | ||
} | ||
label="Disable transition" | ||
/> | ||
</Stack> | ||
</ThemeProvider> | ||
); | ||
} |
71 changes: 71 additions & 0 deletions
71
docs/data/material/customization/css-theme-variables/DisableTransitionOnChange.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as React from 'react'; | ||
import { createTheme, ThemeProvider, useColorScheme } from '@mui/material/styles'; | ||
import Stack from '@mui/material/Stack'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import Switch from '@mui/material/Switch'; | ||
import Select from '@mui/material/Select'; | ||
import FormControlLabel from '@mui/material/FormControlLabel'; | ||
|
||
const theme = createTheme({ | ||
cssVariables: { | ||
colorSchemeSelector: '.demo-disable-transition-%s', | ||
}, | ||
colorSchemes: { dark: true }, | ||
}); | ||
|
||
function ModeSwitcher() { | ||
const { mode, setMode } = useColorScheme(); | ||
if (!mode) { | ||
return null; | ||
} | ||
return ( | ||
<Select | ||
value={mode} | ||
onChange={(event) => | ||
setMode(event.target.value as 'system' | 'light' | 'dark') | ||
} | ||
sx={{ minWidth: 120 }} | ||
> | ||
<MenuItem value="system">System</MenuItem> | ||
<MenuItem value="light">Light</MenuItem> | ||
<MenuItem value="dark">Dark</MenuItem> | ||
</Select> | ||
); | ||
} | ||
|
||
export default function DisableTransitionOnChange() { | ||
const [disableTransition, setDisableTransition] = React.useState(false); | ||
return ( | ||
<ThemeProvider | ||
theme={theme} | ||
disableNestedContext | ||
disableTransitionOnChange={disableTransition} | ||
> | ||
<Stack | ||
sx={{ | ||
width: '100%', | ||
borderRadius: '4px', | ||
p: 2, | ||
gap: 2, | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
bgcolor: 'background.default', | ||
color: 'text.primary', | ||
transition: '1s', | ||
}} | ||
> | ||
<ModeSwitcher /> | ||
<FormControlLabel | ||
control={ | ||
<Switch | ||
checked={disableTransition} | ||
onChange={(event) => setDisableTransition(event.target.checked)} | ||
/> | ||
} | ||
label="Disable transition" | ||
/> | ||
</Stack> | ||
</ThemeProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.