Pure Javascript for Displaying Toast Notifications | toaster-box.js

Toaster is a pure JavaScript plugin for displaying notifications such as custom text or HTML message, duration, custom class, toggle close button, status, custom close icon, and background color.

While toast is often used to describe slices of bread that have been browned with dry heat, it can really refer to any type of item that has been browned in this way.

toast can refer to a non-obtrusive, modal widget used to display expired token (also known as auto-dismiss) windows of information to the user. It does not accept focus or user input and does not interrupt current activity.

Must Read: Create Toaster Notifications with a Few Lines of Code | ToasterJS

How to make use of it:

1. Load the stylesheet toaster-box.css and JavaScript toaster-box.js within the HTML document.

<link rel="stylesheet" href="toaster-box.css" />
<script src="toaster-box.js"></script>

2. Display a primary toast notification on the web page. The message supports each plain text and HTML content:

new ToasterBox({ 
    msg: 'Toast Message Here' 
});
new ToasterBox({ 
    msg: '<strong>Toast</strong> Message Here',
    html : true
});

3. Determine the delay timeout in ms. By default, the toast notification will auto-dismiss after 3 seconds.

new ToasterBox({ 
    msg: 'Toast Message Here',
    duration: 5000
});

4. Determine whether or not to indicate the close button.

new ToasterBox({ 
    msg: 'Toast Message Here',
    closeButton: false
});

5. Customize the close icon.

new ToasterBox({ 
    msg: 'Toast Message Here',
    closeIcon: '<img src='./close.svg' alt='close icon' width='20' class='inverted'/>'
});

6. Determine whether or not to indicate the toast notification on the web page load.

new ToasterBox({ 
    msg: 'Toast Message Here',
    autoOpen: false
});

7. Determine the position of the toast notification: ‘top-left’, ‘top-center’, ‘top-right’, ‘bottom-left’, ‘bottom-center’, ‘bottom-right’.

new ToasterBox({ 
    msg: 'Toast Message Here',
    position: 'bottom-center'
});

8. Set the max-width of the toast notification.

new ToasterBox({ 
    msg: 'Toast Message Here',
    maxWidth: 350
});

9. Apply an additional CSS class to the toast notification.

new ToasterBox({ 
    msg: 'Toast Message Here',
    className: 'your classes here'
});

See Demo And Download

Displaying-Toast-Notifications

Official Website(kvinbabbar): Click Here

This superior jQuery/javascript plugin is developed by kvinbabbar. For extra Advanced Usage, please go to the official website.

Related Posts

Animated-Calendar-UI-Design

Animated Calendar UI Design Using HTML CSS JavaScript

Calendar UI design with dark mode and animations using HTML CSS JavaScript. An elegant, animated, and lightweight (or bold) calendar user interface design implemented in HTML, JS,…

bootstrap-5-dark-theme

Dark & Light Switch Mode Toggle for Bootstrap 5

Switching to dark mode is done by toggling HTML tags that include -dark or -light as a category. It is made by manipulating the DOM with JavaScript. The text color also changes depending…

WYSIWYG-Editor-SunEditor

A Lightweight and Customizable WYSIWYG Editor In Pure JavaScript | SunEditor

WYSIWYG HTML editor based on pure JavaScript, suneditor is a lightweight, versatile, customizable, pure JavaScript WYSIWYG textual content(text) editor in your web functions. Key Features:  Paste from…

disable-background-scrolling-when-popup-modal-is-open

Vue.js Directive To Lock Body Scroll Without Breaking Scroll

v-scroll-lock is a Vue.js directive to lock body scrolling (for iOS mobile and tablet, Android and Safari/Chrome/Firefox for desktop) without breaking the scrolling of the target element….

adjust-text-to-background-js

Jquery Plugin To Adjusting Text Color To Background Color

Adjust-Text-To-Background.js is a jQuery plugin to set the text color to the background color. If the background color is brighter, the script will change the text color…

Leave a Reply

Your email address will not be published. Required fields are marked *