Snackbar
The Snackbar component informs users that an action has been or will be performed by the app.
useSnackbar API
Import
import { useSnackbar } from '@mui/base/useSnackbar';
// or
import { useSnackbar } from '@mui/base';Parameters
The number of milliseconds to wait before automatically calling the
onClose function. onClose should then set the state of the open
prop to hide the Snackbar. This behavior is disabled by default with
the null value.
Type:
number | nullDefault:
nullIf true, the autoHideDuration timer will expire even if the window is not focused.
Type:
booleanDefault:
falseCallback fired when the component requests to be closed.
Typically onClose is used to set state in the parent component,
which is used to control the Snackbar open prop.
The reason parameter can optionally be used to control the response to onClose,
for example ignoring clickaway.
Type:
(event: React.SyntheticEvent<any> | Event | null, reason: SnackbarCloseReason) => voidReturn value
Resolver for the root slot's props.
Type:
<TOther extends Record<string, ((event: any) => void) | undefined> = {}>(externalProps?: TOther) => UseSnackbarRootSlotProps<TOther>