diff --git a/docs/pages/experiments/material-ui/svg-icon.tsx b/docs/pages/experiments/material-ui/svg-icon.tsx new file mode 100644 index 00000000000000..4d10f3437774ce --- /dev/null +++ b/docs/pages/experiments/material-ui/svg-icon.tsx @@ -0,0 +1,81 @@ +import * as React from 'react'; +import { + Experimental_CssVarsProvider as CssVarsProvider, + useColorScheme, +} from '@mui/material/styles'; +import { pink } from '@mui/material/colors'; +import CssBaseline from '@mui/material/CssBaseline'; +import Box from '@mui/material/Box'; +import Button from '@mui/material/Button'; +import Container from '@mui/material/Container'; +import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon'; +import Moon from '@mui/icons-material/DarkMode'; +import Sun from '@mui/icons-material/LightMode'; + +const ColorSchemePicker = () => { + const { mode, setMode } = useColorScheme(); + const [mounted, setMounted] = React.useState(false); + React.useEffect(() => { + setMounted(true); + }, []); + if (!mounted) { + return null; + } + + return ( + + ); +}; + +function HomeIcon(props: SvgIconProps) { + return ( + + + + ); +} + +export default function CssVarsTemplate() { + return ( + + + + + + + div': { + placeSelf: 'center', + }, + }} + > + + + + + + + + + + + + + ); +} diff --git a/packages/mui-material/src/SvgIcon/SvgIcon.js b/packages/mui-material/src/SvgIcon/SvgIcon.js index f3a3b406a2c712..30bbc4534532f0 100644 --- a/packages/mui-material/src/SvgIcon/SvgIcon.js +++ b/packages/mui-material/src/SvgIcon/SvgIcon.js @@ -51,10 +51,10 @@ const SvgIconRoot = styled('svg', { }[ownerState.fontSize], // TODO v5 deprecate, v6 remove for sx color: - theme.palette?.[ownerState.color]?.main ?? + (theme.vars || theme).palette?.[ownerState.color]?.main ?? { - action: theme.palette?.action?.active, - disabled: theme.palette?.action?.disabled, + action: (theme.vars || theme).palette?.action?.active, + disabled: (theme.vars || theme).palette?.action?.disabled, inherit: undefined, }[ownerState.color], }));