Skip to Content
Archi-ui 1.0.25 is released 🎉
ComponentsSnackbar

Snackbar

Snackbar (also known as toasts) are used for brief notifications of processes that have been or will be performed.

The Snackbar component appears themporarily and floats above the UI to provide users with(non-critical) updates on an app’s processes. The demo below inspired by Google keep, shows a basic Snackbar with a text element and two actions:

Usage

import { Snackbar } from 'archi-ui'
<Snackbar message='Basic Snackbar' open={true} />

Automatic dismiss

Use the autoHideDuration prop to automatically trigger the Snackbar’s onClose function after a set period of time (in milliseconds).

Customization

Use with Alerts

Use the Alert inside a Snackbar for messages that communicate a certain severity.

Snackbar with Action

To add the actions to the snackbar use action prop. If want to add multiple actions, use React.Fragment.

Positions

Use the anchorOrigin prop to control the snackbar’s position on the screen.

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.

Snackbar API

API reference docs for the React Snackbar component.

Props

NameTypeDefaultDescription
childrennode-The content of the component.
classNamestring-Override or extend the styles applied to the component
openbool-If true, the component is shown.
messagenode-The message to display.
onClosefunc-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.
Signature: function() => void
autoHideDurationnumbernullThe 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.
actionnode-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.
keyany-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.
Last updated on