vanilla-toaster
v0.0.4
Published
Use Vanilla Toaster Globally
Downloads
5
Maintainers
Readme
Vanilla Toaster
Toast messages globally anywhere inside your app with a single static method.
AnimeJs is used for handling animation.
Installation
Import via NPM.
npm install vanilla-toaster
Or import from CDN https://cdn.jsdelivr.net/npm/vanilla-toaster@latest/dist/vanilla-toaster.js
.
import Toaster from 'https://cdn.jsdelivr.net/npm/vanilla-toaster@latest/dist/vanilla-toaster.js';
Usage
Initialization
import Toaster from 'vanilla-toaster';
const toaster = document.createElement('div');
document.body.appendChild(toaster);
new Toaster(toaster);
Toast anywhere
import Toaster from 'vanilla-toaster';
Toaster.toast('Hello World!');
Customizing
- Select toast type -
info
,success
,warning
,error
.
Toaster.toast('Hello World!', 'success');
- Provide Toast Duration in milliseconds. Default is
2000
. (2 seconds)
Toaster.toast('Hello World!', 'success', 5000);