diff --git a/docs/pages/experiments/material-ui/badge.tsx b/docs/pages/experiments/material-ui/badge.tsx new file mode 100644 index 00000000000000..bccec94d148f11 --- /dev/null +++ b/docs/pages/experiments/material-ui/badge.tsx @@ -0,0 +1,120 @@ +import * as React from 'react'; +import { + Experimental_CssVarsProvider as CssVarsProvider, + useColorScheme, +} from '@mui/material/styles'; +import CssBaseline from '@mui/material/CssBaseline'; +import Badge from '@mui/material/Badge'; +import Box from '@mui/material/Box'; +import Button from '@mui/material/Button'; +import Container from '@mui/material/Container'; +import Moon from '@mui/icons-material/DarkMode'; +import Sun from '@mui/icons-material/LightMode'; +import MailIcon from '@mui/icons-material/Mail'; + +const ColorSchemePicker = () => { + const { mode, setMode } = useColorScheme(); + const [mounted, setMounted] = React.useState(false); + React.useEffect(() => { + setMounted(true); + }, []); + if (!mounted) { + return null; + } + + return ( + + ); +}; + +export default function BadgeCssVars() { + return ( + + + + + + + div': { + placeSelf: 'center', + }, + }} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/packages/mui-material/src/Badge/Badge.js b/packages/mui-material/src/Badge/Badge.js index 479fd46f817b4a..c5ce184f4d8ee7 100644 --- a/packages/mui-material/src/Badge/Badge.js +++ b/packages/mui-material/src/Badge/Badge.js @@ -87,8 +87,8 @@ const BadgeBadge = styled('span', { duration: theme.transitions.duration.enteringScreen, }), ...(ownerState.color !== 'default' && { - backgroundColor: theme.palette[ownerState.color].main, - color: theme.palette[ownerState.color].contrastText, + backgroundColor: (theme.vars || theme).palette[ownerState.color].main, + color: (theme.vars || theme).palette[ownerState.color].contrastText, }), ...(ownerState.variant === 'dot' && { borderRadius: RADIUS_DOT,