Quaff

Notify

Create Material Design snackbars from code anywhere in your app.

Usage

Create a Notification
Notify.create accepts either a message string or an options object. It returns a function that closes that notification.
Notify.create("Preferences saved")
Single Action
Add one action through actions. The notification stays visible until the user selects the action or closes it.
Notify.create({
  message: "Draft deleted",
  actions: [{ label: "Undo", handler: restoreDraft }]
})
Notification Queue
If you create several notifications, they wait in a queue and appear one at a time.
Close from Code
Set timeout to zero to keep a notification visible. Notify.create returns a function that closes it. Call that function when the message is no longer needed.
const dismiss = Notify.create({
  message: "You are offline",
  timeout: 0
})

// When the connection returns
dismiss()
Defaults
Notify.setDefaults replaces the defaults used by later notifications. Call it without arguments to reset them.
Supported Features
Notify supports one action and shows one snackbar at the bottom. It does not support extra positions, captions, or decorative icons because Material Design snackbars do not use them. Use the QSnackbar component when one component controls when it is shown.