Snackbar

Displays an important message globally. 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.

Only one snackbar may be displayed at a time.

Simple Snackbars

Placement

You can use placement property to change the snackbar's horizontal placement.

Color

You can use color property to change the snackbar's color.

API

Learn more about the properties and the customization points.

Usage

import Snackbar from "@sonnat/ui/Snackbar";
//or
import { Snackbar } from "@sonnat/ui";

Properties

Note that the documentation avoids mentioning all the native props (there are a lot) in this section of the components.

Snackbar Properties
NameTypeDefaultDescription
text
required
string-The text to display.
classNamestring-Append to the class names applied to the component so you can override or extend the styles.
actionLabelstring-The text to display on the action button.
iconnode-The leading icon element placed before the text.
placement"left"
| "center"
| "right"
"center"The horizontal placement of the snackbar.
autoHideboolean
| number
falseIf true, the snackbar automatically closes after a calculated time.
This calculated time depends on the number of characters in the snackbar's content.
If a number is entered, the snackbar will be closed after that amount of time (in miliseconds).
openbooleanfalseIf true, the snackbar will be open.
closablebooleanfalseIf true, the snackbar will have close button.
color"default"
| "success"
| "warning"
| "error"
| "info"
"default"The color of the snackbar.
onClosefunction-The callback fires when the component has closed.
Signature: function() => void
actionCallbackfunction-The Callback fires when the action button is clicked.
Signature: function() => void
  • The ref is forwarded to the root element.
  • Any other properties supplied will be provided to the root element.