Lightweight and easily customizable notification library.
npm install leti.js --save-dev
Create Leti instance.
const leti = new Leti();
Now you can simply call one of the default success
, error
, warning
, info
methods.
leti.error("Oops, there was an error.");
//OR
leti.error({
title: "Something went wrong..",
message: "We had some trouble while processing your request"
});
You can create your own types of notification methods with different settigns passing a types
Object into the constructor.
const leti = new Leti({
types: {
alert: {
delay: 2000,
icon: "alert-icon",
position: "top right",
},
push: {} //use all defaults
},
})
Options can be treated as global by placing them on the root level of the options object and then overriden by a specific notification type.
const leti = new Leti({
position: "botom right", // default position
types: {
push: {
position: "top right" // override positioning
}
}
})
Option | Type | Default | Details |
---|---|---|---|
position | String | bottom right | [top,bottom] [left,right,center] |
delay | Number | 2000 | Number of miliseconds the notification should be visible |
icon | String | - | Icon class |