Snackbar API
The API documentation of the Snackbar React component. Learn more about the properties and the CSS customization points.
import Snackbar from '@material-ui/core/Snackbar';Props
| Name | Type | Default | Description | 
|---|---|---|---|
| action | node | The action to display. | |
| anchorOrigin | { horizontal: enum: 'left' | 'center' | 'right' , vertical: enum: 'top' | 'bottom' } | { vertical: 'bottom', horizontal: 'center',} | The anchor of the Snackbar. | 
| autoHideDuration | number | 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. | |
| children | element | Replace the SnackbarContentcomponent. | |
| classes | object | Override or extend the styles applied to the component. See CSS API below for more details. | |
| ClickAwayListenerProps | object | Properties applied to the ClickAwayListenerelement. | |
| ContentProps | object | Properties applied to the SnackbarContentelement. | |
| disableWindowBlurListener | bool | false | If true, theautoHideDurationtimer will expire even if the window is not focused. | 
| key | any | When displaying multiple consecutive Snackbars from a parent rendering a single <Snackbar/>, add the key property to ensure independent treatment of each message. e.g. <Snackbar key={message} />, otherwise, the message may update-in-place and features such as autoHideDuration may be canceled. | |
| message | node | The message to display. | |
| onClose | func | 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.Signature: function(event: object, reason: string) => voidevent: The event source of the callback reason: Can be: "timeout"(autoHideDurationexpired) or:"clickaway" | |
| onEnter | func | Callback fired before the transition is entering. | |
| onEntered | func | Callback fired when the transition has entered. | |
| onEntering | func | Callback fired when the transition is entering. | |
| onExit | func | Callback fired before the transition is exiting. | |
| onExited | func | Callback fired when the transition has exited. | |
| onExiting | func | Callback fired when the transition is exiting. | |
| open | bool | If true, Snackbaris open. | |
| resumeHideDuration | number | The number of milliseconds to wait before dismissing after user interaction. If autoHideDurationproperty isn't specified, it does nothing. IfautoHideDurationproperty is specified butresumeHideDurationisn't, we default toautoHideDuration / 2ms. | |
| TransitionComponent | componentPropType | Slide | The component used for the transition. | 
| transitionDuration | union: number | { enter?: number, exit?: number } | { enter: duration.enteringScreen, exit: duration.leavingScreen,} | The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object. | 
| TransitionProps | object | Properties applied to the Transitionelement. | 
Any other properties supplied will be spread to the root element (native element).
CSS
You can override all the class names injected by Material-UI thanks to the classes property.
This property accepts the following keys:
| Name | Description | 
|---|---|
| root | Styles applied to the root element. | 
| anchorOriginTopCenter | Styles applied to the root element if anchorOrigin={{ 'top', 'center' }}. | 
| anchorOriginBottomCenter | Styles applied to the root element if anchorOrigin={{ 'bottom', 'center' }}. | 
| anchorOriginTopRight | Styles applied to the root element if anchorOrigin={{ 'top', 'right' }}. | 
| anchorOriginBottomRight | Styles applied to the root element if anchorOrigin={{ 'bottom', 'right' }}. | 
| anchorOriginTopLeft | Styles applied to the root element if anchorOrigin={{ 'top', 'left' }}. | 
| anchorOriginBottomLeft | Styles applied to the root element if anchorOrigin={{ 'bottom', 'left' }}. | 
Have a look at overriding with classes section and the implementation of the component for more detail.
If using the overrides key of the theme,
you need to use the following style sheet name: MuiSnackbar.