useSnackbar API
Demos
For examples and details on the usage of this React hook, visit the demo pages:
Import
import { useSnackbar } from '@mui/base/SnackbarUnstyled';The basic building block for creating custom snackbar.
Parameters
| Name | Type | Default | Description | 
|---|---|---|---|
| autoHideDuration | number | null | null | The number of milliseconds to wait before automatically calling the
 onClosefunction.onCloseshould then set the state of theopenprop to hide the Snackbar. This behavior is disabled by default with
thenullvalue. | 
| disableWindowBlurListener | boolean | false | If  true, theautoHideDurationtimer will expire even if the window is not focused. | 
| onClose | (event: React.SyntheticEvent<any> | Event | null, reason: SnackbarCloseReason) => void | Callback fired when the component requests to be closed.
Typically  onCloseis used to set state in the parent component,
which is used to control theSnackbaropenprop.
Thereasonparameter can optionally be used to control the response toonClose,
for example ignoringclickaway. | |
| open | boolean | If  true, the component is shown. | |
| ref | React.Ref<any> | ||
| resumeHideDuration | number | The number of milliseconds to wait before dismissing after user interaction.
If  autoHideDurationprop isn't specified, it does nothing.
IfautoHideDurationprop is specified butresumeHideDurationisn't,
we default toautoHideDuration / 2ms. | 
Return value
| Name | Type | Default | Description | 
|---|