diff --git a/docs/pages/experiments/material-ui/snackbar.tsx b/docs/pages/experiments/material-ui/snackbar.tsx new file mode 100644 index 00000000000000..d67f71597ef864 --- /dev/null +++ b/docs/pages/experiments/material-ui/snackbar.tsx @@ -0,0 +1,91 @@ +import * as React from 'react'; +import { + Experimental_CssVarsProvider as CssVarsProvider, + useColorScheme, +} from '@mui/material/styles'; +import CssBaseline from '@mui/material/CssBaseline'; +import Box from '@mui/material/Box'; +import Container from '@mui/material/Container'; +import Moon from '@mui/icons-material/DarkMode'; +import Sun from '@mui/icons-material/LightMode'; +import Button from '@mui/material/Button'; +import Snackbar from '@mui/material/Snackbar'; +import MuiAlert, { AlertProps } from '@mui/material/Alert'; + +const Alert = React.forwardRef(function Alert(props, ref) { + return ; +}); + +const ColorSchemePicker = () => { + const { mode, setMode } = useColorScheme(); + const [mounted, setMounted] = React.useState(false); + React.useEffect(() => { + setMounted(true); + }, []); + if (!mounted) { + return null; + } + + return ( + + ); +}; + +export default function SnackbarCssVars() { + const [open, setOpen] = React.useState(false); + const handleClick = () => { + setOpen(true); + }; + + const handleClose = (event?: React.SyntheticEvent | Event, reason?: string) => { + if (reason === 'clickaway') { + return; + } + + setOpen(false); + }; + + return ( + + + + + + + div': { + placeSelf: 'center', + }, + }} + > + + + + + This is a success message! + + + + + + + ); +} diff --git a/packages/mui-material/src/Snackbar/Snackbar.js b/packages/mui-material/src/Snackbar/Snackbar.js index e703d96878826e..fd3fd5976e1d5c 100644 --- a/packages/mui-material/src/Snackbar/Snackbar.js +++ b/packages/mui-material/src/Snackbar/Snackbar.js @@ -55,7 +55,7 @@ const SnackbarRoot = styled('div', { }; return { - zIndex: theme.zIndex.snackbar, + zIndex: (theme.vars || theme).zIndex.snackbar, position: 'fixed', display: 'flex', left: 8,