Skip to content

Snackbar API

API reference docs for the React Snackbar component. Learn about the props, CSS, and other APIs of this exported module.



import Snackbar from '@mui/material/Snackbar';
// or
import { Snackbar } from '@mui/material';

Learn about the difference by reading this guide on minimizing bundle size.


Props of the native component are also available.


The action to display. It renders after the message, at the end of the snackbar.

anchorOrigin{ horizontal: 'center'
| 'left'
| 'right', vertical: 'bottom'
| 'top' }
{ vertical: 'bottom', horizontal: 'left' }

The anchor of the Snackbar. On smaller screens, the component grows to occupy all the available width, the horizontal alignment is ignored.


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.


Replace the SnackbarContent component.


Override or extend the styles applied to the component.

See CSS classes API below for more details.


Props applied to the ClickAwayListener element.


Props applied to the SnackbarContent element.


If true, the autoHideDuration timer will expire even if the window is not focused.


When displaying multiple consecutive snackbars using a single parent-rendered <Snackbar/>, add the key prop to ensure independent treatment of each message. For instance, use <Snackbar key={message} />. Otherwise, messages might update in place, and features like autoHideDuration could be affected.


The message to display.


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: React.SyntheticEvent | Event, reason: string) => void
  • event The event source of the callback.
  • reason Can be: "timeout" (autoHideDuration expired), "clickaway", or "escapeKeyDown".

If true, the component is shown.


The number of milliseconds to wait before dismissing after user interaction. If autoHideDuration prop isn't specified, it does nothing. If autoHideDuration prop is specified but resumeHideDuration isn't, we default to autoHideDuration / 2 ms.

| object
| bool>
| func
| object

The system prop that allows defining system overrides as well as additional CSS styles.

See the `sx` page for more details.


The component used for the transition. Follow this guide to learn more about the requirements for this component.

| { appear?: number, enter?: number, exit?: number }
{ enter: theme.transitions.duration.enteringScreen, exit: theme.transitions.duration.leavingScreen, }

The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object.


Props applied to the transition element. By default, the element is based on this Transition component.

The ref is forwarded to the root element.

Theme default props

You can use MuiSnackbar to change the default props of this component with the theme.

CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

Class nameRule nameDescription
.MuiSnackbar-anchorOriginBottomCenteranchorOriginBottomCenterStyles applied to the root element if anchorOrigin={{ 'bottom', 'center' }}.
.MuiSnackbar-anchorOriginBottomLeftanchorOriginBottomLeftStyles applied to the root element if anchorOrigin={{ 'bottom', 'left' }}.
.MuiSnackbar-anchorOriginBottomRightanchorOriginBottomRightStyles applied to the root element if anchorOrigin={{ 'bottom', 'right' }}.
.MuiSnackbar-anchorOriginTopCenteranchorOriginTopCenterStyles applied to the root element if anchorOrigin={{ 'top', 'center' }}.
.MuiSnackbar-anchorOriginTopLeftanchorOriginTopLeftStyles applied to the root element if anchorOrigin={{ 'top', 'left' }}.
.MuiSnackbar-anchorOriginTopRightanchorOriginTopRightStyles applied to the root element if anchorOrigin={{ 'top', 'right' }}.
.MuiSnackbar-rootrootStyles applied to the root element.

You can override the style of the component using one of these customization options: