Toast.js

A JavaScript prototype for Toast messages

Made with by @IreAderinokun

Getting Started

Create a Toast -

new Toast(options)

Options

Examples

Simple

The only required option you need to pass is the message that is displayed in the toast. This example below is the Toast that comes up when you first visit this page

new Toast({message: 'Welcome to Toast.js!'});

Toast Style

new Toast({
  message: 'This is a danger message. You can use this for errors etc',
  type: 'danger'
});

Custom Button Functions

new Toast({
  message: 'This is an example with custom buttons',
  type: 'success',
  customButtons: [
    {
      text: 'Refresh the page',
      onClick: function() {
        window.location.reload();
      }
    },
    {
      text: 'Follow @ireaderinokun',
      onClick: function() {
        window.open('https://twitter.com/ireaderinokun');
      }
    }
  ]
});