Snackbar

Snackbars provide brief messages about app processes. The component is also known as a toast.

Snackbars inform users of a process that an app has performed or will perform. They appear temporarily, towards the bottom of the screen. They shouldn’t interrupt the user experience, and they don’t require user input to disappear.

Usage

Ideally, an app should not render more than one instance of Snackbar. Snackbar appears on the screen whenever either message or intent prop is changed.

Examples

Default Snackbar

Here, whenever message prop is changed new Snackbar pops-up on the screen.

Snackbar Placements

Select...
open

Snackbar Intent

Render custom component as message

Snackbar props

NameTypeDefaultDescription
autoHide
boolean
trueHides Snackbar after `autoHideDuration`.
autoHideDuration
number
Duration(in ms) after which the Snackbar should autoHide itself. If `autoHide` is false, value will be ignored.
disableManualClose
boolean
falseIf true, close icon will not be visible.
hideOnClickAway
boolean
trueIf false, snackbar will not close on clicking away.
intent
'success' | 'error' | 'warning'
successIntent of the snackbar. Default autoHideDuration will be different for different intent.
message
react node
Message to be displayed in Snackbar.
onClose
function
Called when Snackbar closes.
overrides
custom
Lets you customize all aspects of the component.
placement
'topLeft' | 'top' | 'topRight' | 'bottomLeft' | 'bottom' | 'bottomRight'
bottomPlacement of the Snackbar.

You can check the implementation of the component for more details.

Snackbar exports

You can import this module like so:

import {Snackbar} from 'spaceweb/snackbar'

It exports the following components or utility functions:

  • Snackbar