🍫 React Snackbar Alert

API

SnackbarProvider Component

Props

Unless otherwise noted, any of these props can be overridden for a specific snackbar instance by adding that same property to the object passed to createSnackbar.

NameTypeDefaultDescription
animationTimeoutnumber500The duration of the show and hide animations, in milliseconds
componentReact component typeSnackbar componentThe component type to use for rendering the snackbar. Cannot be overridden for an individual snackbar.
dismissablebooleanfalseWhether or not created snackbars can be manually dismissed by the user
pauseOnHoverbooleanfalseWhether or not to pause a snackbar's timeout when the mouse is hovered over it
positionOne of:
  • 'top'
  • 'top-left'
  • 'top-right'
  • 'bottom'
  • 'bottom-left'
  • 'bottom-right'
'bottom'The position on screen to show the snackbars. Cannot be overridden for an individual snackbar.
progressBarbooleantrueWhether or not to show an animated progress bar indicating the time before a snackbar is removed
stickybooleanfalseWhether or not the snackbars should be sticky
timeoutnumber3000The time before a snackbar is automatically removed, in milliseconds

Context

createSnackbar(snackbar: SnackbarData)

Creates and shows a snackbar notification.

SnackbarData type

When a value is specified for a given property in both the SnackbarManager component and a SnackbarData item, the value in the SnackbarData takes precedence. Otherwise, it will default to the corresponding setting in the SnackbarManager if not specified.
NameTypeDescription
animationTimeoutnumberThe duration of the show and hide animations, in milliseconds
dataobjectCustom data that can be used with a custom snackbar component
dismissablebooleanWhether or not this snackbar can be manually dismissed by the user
message (Required)stringThe message to display
pauseOnHoverbooleanWhether or not to pause this snackbar's timeout when it is hovered over
progressBarbooleanWhether or not to show the progress bar for this snackbar
stickybooleanWhether or not this snackbar should be sticky. Sticky snackbars are not automatically removed.
themeOne of:
  • 'default'
  • 'info'
  • 'success'
  • 'warning'
  • 'error'
The theme to use for this snackbar. Default is 'default'.
timeoutnumberThe time before this snackbar is automatically removed, in milliseconds

wrapComponent helper

This helper function wraps the passed component, adding the createSnackbar function prop to the wrapped component.