Notifications

We added a sleek notification api with a lot of possibilites. Play around with the form to try it out!

Firing a notification in your code is as simple as:

notification.fire('This is a notification');

Available options for a single notification

notification.fire('This is a notification', {
  autoHide: false,
  playSound: true,
  duration: 5000,
  style: 'default',
});

Notifications need to be initalized before you can use them. It's as simple as:

const notifications = new window.notifications();

There comes a set of options you can override on initialization.

const notifications = new window.notifications({
  notificationSound: '../dist/media/notification.mp3',
  volume: 0.2,
  notification: {
    autoHide: false,
    playSound: true,
    duration: 5000,
    style: 'default',
    position: 'top',
  }
});
Demo
It will close after 5 seconds by default but you can pass the duration when you fire a notification!