37 lines
848 B
JavaScript
37 lines
848 B
JavaScript
|
|
import * as React from 'react';
|
||
|
|
import Button from '@mui/material/Button';
|
||
|
|
import Snackbar from '@mui/material/Snackbar';
|
||
|
|
import Alert from '@mui/material/Alert';
|
||
|
|
|
||
|
|
export default function CustomizedSnackbars() {
|
||
|
|
const [open, setOpen] = React.useState(false);
|
||
|
|
|
||
|
|
const handleClick = () => {
|
||
|
|
setOpen(true);
|
||
|
|
};
|
||
|
|
|
||
|
|
const handleClose = (event, reason) => {
|
||
|
|
if (reason === 'clickaway') {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
setOpen(false);
|
||
|
|
};
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div>
|
||
|
|
<Button onClick={handleClick}>Open Snackbar</Button>
|
||
|
|
<Snackbar open={open} autoHideDuration={6000} onClose={handleClose}>
|
||
|
|
<Alert
|
||
|
|
onClose={handleClose}
|
||
|
|
severity="success"
|
||
|
|
variant="filled"
|
||
|
|
sx={{ width: '100%' }}
|
||
|
|
>
|
||
|
|
This is a success Alert inside a Snackbar!
|
||
|
|
</Alert>
|
||
|
|
</Snackbar>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|