A vanilla JavaScript toast library

Overview

Vanilla Toasts (also refered to as vtoast) is a lightweight VanillaJS toast library. It does not require any framework to run. It is inspired from toastr but removes the dependency to jQuery.

It's also lighter and has fewer lines of code.

It is currently in active development thus some features mentioned below might not be (yet) implemented. Additional features may also be developed.

Current version: 1.0.0

Known issues with the current code:

  • None

States

A toast has 3 states

  • Hidden: The toast is either in the process of being created or deleted.
  • Shown: The toast is visible for the time set in the duration option.
  • Focused: The toast is frozen in time (the auto-remove is cancelled). Happens when the cursor enters the toast. Once the cursor leaves the toast, the toast will remain in a "shown" state for the time set in the unfocus-duration option.

Usage

To start with, include the CSS and the JavaScript (where PATH is the installation path or URL)

<link rel="stylesheet" href="PATH/vtoast.css">
<script src="PATH/vtoast.js"></script>

And you are ready to bring quality toasts to your website.

Consider the 3 variables below:

let title;
let content;
let options;

title and content are strings, options is a JSON.

Content only

If you pass only one parameter to the show method, it will be used as content and the default options set will be used.

vtoast.show(content);

Title and content

You can pass the title and the content to the show method, the default options set will be used.

vtoast.show(title, content);

Title, content and options

You can take full control and pass the title, the content and the options to the show method.

vtoast.show(title, content, options);

Options

Options are passed to the show method as a "one depth" JSON object.

Option key Default value Description/Possible values
width 350 Defines the width (in px) of the toast. Any Number
margin 10 Defines the margin (in px) around the toast. Any Number
color #004085 (bootstrap's primary) Defines the font color of the toast. Any hex value
backgroundcolor #CCE5FF (bootstrap's primary) Defines the background color of the toast. Any hex value
duration 5000 The time (in ms) during which the toast will be visible. Any number
unfocusduration 1000 The time (in ms) that the toast will remain visible after it as been unfocused
position top-right The position of the toast. Any combination of top|middle|bottom-left|centre|right
showclose false Whether or not to show a close icon on the toast. true or false.
progressbar hidden The position of the progress bar in the toast. Either hidden, top or bottom. Performance note: when using hidden, the progress bar is disabled and the code is not included (It's not simply "hidden" through CSS).
opacity 1 The opacity of the toast. Any decimal number between 0 and 1.
You might also like...

A lightweight scrollbar library written in vanilla javascript.

A lightweight scrollbar library written in vanilla javascript.

A lightweight, dependency-free scrollbar library written in vanilla javascript. Fully customisable via CSS Native scrolling behaviour preserved Vertic

Dec 4, 2022

A vanilla JavaScript library that automatically generates the "Table of Contents" of an HTML document.

DocumentOutline.js DocumentOutline is a vanilla JavaScript library that automatically generates the "Table of Contents" of an HTML document. See a liv

Jul 12, 2021

A very simple JavaScript library written in vanilla js for scrambling text.

A very simple JavaScript library written in vanilla js for scrambling text.

Scrambling Text A very simple JavaScript library written in vanilla js for scrambling text. Demo Page Table of Contents Installation Examples Basic Ex

Dec 7, 2022

A vanilla javascript library to generate Avataaars on the client or server side!

A vanilla javascript library to generate Avataaars on the client or server side!

Use the awesome Avataaars Library by Pablo Stanley (avataaars.com) in any javascript application. This Project uses parts of the Dicebear Avatars Libr

Dec 4, 2022

🍦 ✨ Simple multi-select pure vanilla Javascript library.

🍦 ✨ Simple multi-select pure vanilla Javascript library.

multiSelect.js ✨ Simple multi-select pure vanilla Javascript library. 🚀 Live Demo v1.0.8 multiSelect.js is a simple, pure vanilla Javascript library

Mar 15, 2022

A simple easy to use vanilla JavaScript library for creating input fields that accept multiple email addresses

MeiMei - Multiple Email Input MeiMei: A simple easy to use vanilla JavaScript library for creating input fields that accept multiple email addresses.

Apr 13, 2022

A lightweight vanilla JavaScript context menu library with FontAwesome support.

A lightweight vanilla JavaScript context menu library with FontAwesome support.

Contextify A lightweight vanilla JavaScript context menu library with FontAwesome support. This library was written for use in a personal project of m

Jun 1, 2022

A modern JavaScript library for vanilla spreadsheets

Spreadsheet.js Landing page: https://spread-sheet.herokuapp.com/index.html Documentation: https://spread-sheet.herokuapp.com/documentation.html Gettin

Feb 23, 2022

Navigation-Menu-Javascript - A simple Navbar navigation using vanilla javascript, to change links to the active link when clicked.

Navigation-Menu-Javascript - A simple Navbar navigation using vanilla javascript, to change links to the active link when clicked.

Navigation-Menu-Javascript A simple Navbar navigation using vanilla javascript, to change links to the active link when clicked. Desktop view Mobile v

Feb 16, 2021
Comments
  • Progressbar not appearing

    Progressbar not appearing

    Nice implementation, however, I have noticed that the progressbar does not appear on the first toast when using:

    onclick="vtoast.show('With Title', 'With Toast Title',{progressbar:'bottom'})"

    The progressbar only appears if there is an existing toast visible in the DOM. Example: On the following demo click the 'With Progressbar' button first: https://www.cssscript.com/demo/animated-toast-popup/

    opened by David-Carty 0
Releases(v1.0.0)
Owner
Paper Development
Paper Development
Vanilla JS toast notification.

Toasting Toasting - is a javascript library for notifications. There is no dependencies needed. Installing There is no npm or cdn is available yet. by

Tharith Phon 1 Jun 30, 2022
EggyJS is a Javascript micro Library for simple, lightweight toast popups focused on being dependency-less, lightweight, quick and efficient.

EggyJS EggyJS is a Javascript micro Library for simple, lightweight toast popups. The goal of this library was to create something that meets the foll

Sam 10 Jan 8, 2023
A simple and light jquery library for toast notification!

What is notify message? Notify message it's a simple jquery library for create a simple and light push notification in your website! How does this wor

Ivan Persiani 3 Feb 23, 2022
✨ Small and Clean JavaScript Toast Notifications

BuzzNotify Small and Clean JavaScript Toast Notifications New version introduces breaking changes! Now the styles come separately and you will have to

R. Eliut 9 Aug 23, 2022
Kuldeep 2 Jun 21, 2022
A simple, jQuery free Snackbar (Toast) alert

js-snackbar What is a SnackBar? According to Material Design a Snackbar or Toast provides "brief messages about app processes at the bottom of the scr

Michael Mickelson 43 Jan 5, 2023
Jquery Plugin for Make easy Toast

Nice Toast JS nice and easy toast for jquery Requirements jQuery Installation NPM npm install nice-toast-js Yarn yarn add nice-toast-js CDN - jsDelivr

Hasan Ahani 4 Jul 26, 2022
This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Eduardo Dantas 7 Jul 19, 2022
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.

What is it ? Shaders are the new front-end web developpment big thing, with the ability to create very powerful 3D interactions and animations. A lot

Martin Laxenaire 1.4k Jan 1, 2023
Lightweight and simple notification library in Vanilla JavaScript.

SimpleNotification SimpleNotification is a library to display simple yet customizable notifications. You can stylize text with a simple syntax, add bu

null 14 Dec 11, 2022