Snackbars

Snackbars provide brief feedback about an operation through a message - typically at the bottom of the screen. Snackbars contain a single line of text directly related to the operation performed. They may contain a text action, but no icons.

Simple

To show this type of Snackbars you will need this code in down here.

     
 <Button variant="raised" color="primary" onClick={this.handleClick}>
                    {this.props.children}
</Button>
<Snackbar
        anchorOrigin={{
        vertical: 'bottom',
        horizontal: 'left',
         }}
    open={this.state.open}
    autoHideDuration={6e3}
    onClose={this.handleRequestClose}
    SnackbarContentProps={{
        'aria-describedby': 'message-id',
    }}
    message={<span id="message-id">Note archived</span>}
    action={[
        <Button key="undo" color="secondary" size="small" onClick={this.handleRequestClose}>
            UNDO
        </Button>,
        <IconButton
                key="close"
                aria-label="Close"
                color="inherit"
                onClick={this.handleRequestClose}>
            <CloseIcon/>
        </IconButton>,
       ]}
 />
  

Available parameters, type and descriptions are down below.

Name Type Default Description
action node The action to display.
anchorOrigin {horizontal?: union: number |
 enum: 'left' |
 'center' |
 'right'

, vertical?: union: number |
 enum: 'top' |
 'center' |
 'bottom'

}
{ vertical: 'bottom', horizontal: 'center',} The anchor of the Snackbar.
autoHideDuration number 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.
children element If you wish the take control over the children of the component you can use this property. When used, you replace the SnackbarContent component with the children.
classes object Useful to extend the style applied to components.
ContentProps object Properties applied to the SnackbarContent element.
disableWindowBlurListener bool false If true, the autoHideDuration timer 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 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.

Signature:
function(event: object, reason: string) => void
event: The event source of the callback
reason: Can be:"timeout" (autoHideDuration expired) 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, Snackbar is open.
resumeHideDuration number The number of milliseconds to wait before dismissing after user interaction. If autoHideDuration property isn't specified, it does nothing. If autoHideDuration property is specified but resumeHideDuration isn't, we default to autoHideDuration / 2 ms.
TransitionComponent union: string |
 func
Slide Transition component.
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 Transition element.