Hone UI
Components

Snackbar

A brief message at the edge of the screen.

Snackbar shows a short message about an action the user took. SnackbarContent is the bar it shows; pass an Alert as the child to show a colored message instead.

import Snackbar from '@hone-ui/react/Snackbar';
import SnackbarContent from '@hone-ui/react/SnackbarContent';

Examples

<SnackbarContent
  message="Message archived"
  action={
    <Button color="inherit" size="small">
      Undo
    </Button>
  }
/>

Snackbar props

PropTypeDefaultDescription
openbooleanfalseShows it.
onClose(event, reason) => voidreason is timeout, clickaway or escapeKeyDown.
message, actionReactNodeThe content of the bar.
childrenelementReplaces the bar, for example with an Alert.
autoHideDurationnumber, nullnullMilliseconds before it asks to close.
resumeHideDurationnumberhalf of autoHideDurationTime left after the pointer or focus leaves.
anchorOrigin{ vertical, horizontal }{ vertical: 'bottom', horizontal: 'left' }Where it sits.
disableWindowBlurListenerbooleanfalseKeeps the timer running in a background window.
ContentProps, slotProps.contentSnackbarContent propsProps for the bar.
sx, className, style, refStandard.

SnackbarContent takes message, action and role ('alert').

Notes

  • The timer pauses on hover, on focus and while the window is in the background.
  • TransitionComponent, TransitionProps and ClickAwayListenerProps are not supported.

Accessibility

SnackbarContent has role="alert". Give users enough time to read, and don't time out a message whose action they need.

On this page