-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0010fda
commit 016c62d
Showing
5 changed files
with
46 additions
and
29 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
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,42 @@ | ||
import * as React from "react"; | ||
import Stack from "@mui/material/Stack"; | ||
import Button from "@mui/material/Button"; | ||
import Snackbar from "@mui/material/Snackbar"; | ||
import MuiAlert, { AlertProps } from "@mui/material/Alert"; | ||
|
||
const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(props, ref) { | ||
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />; | ||
}); | ||
|
||
export default function Snackbars() { | ||
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 ( | ||
<Stack spacing={2} sx={{ width: "100%" }}> | ||
<Button variant="outlined" onClick={handleClick}> | ||
Open success snackbar | ||
</Button> | ||
<Snackbar open={open} autoHideDuration={3000} onClose={handleClose}> | ||
<Alert onClose={handleClose} severity="info" sx={{ width: "100%" }}> | ||
This is a success message! | ||
</Alert> | ||
</Snackbar> | ||
<Alert severity="error">This is an error message!</Alert> | ||
<Alert severity="warning">This is a warning message!</Alert> | ||
<Alert severity="info">This is an information message!</Alert> | ||
<Alert severity="success">This is a success message!</Alert> | ||
</Stack> | ||
); | ||
} |
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
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
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