@mui/material APIs
- Button
- IconButton
- Typography
- MenuItem
- Box
- Tooltip
- TextField
- CircularProgress
- FormControlLabel
- List
- Divider
- ListItem
- ListItemText
- Select
- Grid
- ThemeProvider
- FormControl
- Link
- useTheme
- InputLabel
- Paper
- Dialog
- DialogTitle
- Toolbar
- createTheme
- LinearProgress
- Container
- Checkbox
- ListItemIcon
- DialogContent
- Card
- CssBaseline
- Theme
- useMediaQuery
- Menu
- Alert
- Tab
- DialogActions
- AppBar
- Switch
- Drawer
- Chip
- InputAdornment
- Collapse
- Stack
- CardContent
- DialogContentText
- TableBody
- TableCell
- TableRow
- Skeleton
- Table
- Tabs
- Avatar
- Autocomplete
- FormGroup
- SelectChangeEvent
- Radio
- AlertTitle
- TableHead
- InputBase
- Input
- Snackbar
- TextFieldProps
- styled
- alpha
- TableContainer
- CardActions
- Badge
- CardHeader
- ListItemButton
- CardActionArea
- Modal
- AccordionDetails
- AccordionSummary
- ButtonProps
- StyledEngineProvider
- RadioGroup
- ListItemAvatar
- Fade
- CardMedia
- Accordion
- Slider
- FormLabel
- FormHelperText
- Popover
- Backdrop
- Popper
- ThemeOptions
- Zoom
- ToggleButton
- ToggleButtonGroup
- SxProps
- Fab
- TooltipProps
- IconButtonProps
- CircularProgressProps
- darken
- TextareaAutosize
- OutlinedInput
- Breadcrumbs
- Slide
- SwipeableDrawer
- ClickAwayListener
- SelectProps
- TypographyProps
- ButtonBase
- ListItemSecondaryAction
- SvgIcon
- Pagination
- tooltipClasses
- ButtonGroup
- Hidden
- debounce
- FilledInput
- lighten
- useScrollTrigger
- darkScrollbar
- PaletteMode
- SnackbarCloseReason
- MenuList
- SvgIconProps
- SnackbarProps
- AlertColor
- Icon
- TablePagination
- MenuItemProps
- Stepper
- Step
- StepLabel
- ownerWindow
- useForkRef
- AlertProps
- InputUnstyled
- Rating
- capitalize
- SpeedDial
- SpeedDialAction
- SpeedDialIcon
- BadgeProps
- createSvgIcon
- Grow
- linearProgressClasses
- PaletteColor
- BottomNavigation
- Palette
- responsiveFontSizes
- OutlinedInputProps
- TabProps
- NoSsr
- PaletteOptions
- ListSubheader
- ImageList
- StepConnector
- tableCellClasses
- TableSortLabel
Other Related APIs
@mui/material#SnackbarCloseReason TypeScript Examples
The following examples show how to use
@mui/material#SnackbarCloseReason.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Message.tsx From your_spotify with GNU General Public License v3.0 | 6 votes |
export default function Message() {
const message = useSelector(selectMessage);
const [open, setOpen] = useState(false);
const onClose = useCallback(
(_: Event | React.SyntheticEvent<any, Event>, reason: SnackbarCloseReason) => {
if (reason === 'clickaway') {
return;
}
setOpen(false);
},
[],
);
useEffect(() => {
setOpen(true);
}, [message]);
if (!message) {
return null;
}
return (
<Snackbar
open={open}
autoHideDuration={2000}
onClose={onClose}
anchorOrigin={{ horizontal: 'center', vertical: 'top' }}>
<Alert onClose={() => setOpen(false)} level={message.level} message={message.message} />
</Snackbar>
);
}
Example #2
Source File: Snackbar.tsx From frontend with MIT License | 6 votes |
function SnackBar() {
const { getAlerts } = AlertStore
const handleSnackBarClose = (
_event: React.SyntheticEvent | Event,
reason: SnackbarCloseReason,
) => {
if (reason === 'clickaway') {
return
}
AlertStore.hide()
}
const handleClose = () => AlertStore.hide()
return (
<>
{getAlerts.map(({ id, show, duration, type, message }) => {
return (
<Snackbar
key={id}
open={show}
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
autoHideDuration={duration}
onClose={handleSnackBarClose}>
<Alert severity={type} onClose={handleClose}>
{message}
</Alert>
</Snackbar>
)
})}
</>
)
}