Snackbars provide brief feedback about an operation through a message.
import { SnackbarService, SnackbarRef } from "@ssv/au-ui";
// inject it (within a class) e.g.
constructor(
private snackbarService: SnackbarService
)
// open
const snackbarRef = this.snackbarService.open(`Message sent!`);
// open - with action + options
const snackbarRef = this.snackbarService.open("You have been disconnected", "Reconnect", {
duration: 5000
});
// dismiss - active only
this.snackbarService.dismiss();
// dimissAll - queued and active
this.snackbarService.dismissAll();
Reference returned when opening a snackbar.
// onDismiss - subscribe on dismiss callback
snackbarRef.onDismiss(() => {
// ...
});
// onAction - subscribe on action callback
snackbarRef.onAction(() => {
// ...
});
// dismiss - dismisses the snackbar
snackbarRef.dismiss();
Options which can be configured globally.
Name | Type | Default | Description |
---|---|---|---|
duration | number |
3000 |
Duration in milliseconds before automatically dismisses the snackbar. |
actionType | ButtonType |
flat |
Button type for the action. Read button doc for more info. |
actionColor | string |
"accent" |
Button color for the action. Read button doc for more info. |
- dismiss by gesture - swipe off screen
- custom snackbar component