Unread-Messages.js is a lightweight library that lets a user add floating number notifications to any object.

Overview

Unread-Messages.js

unread

About

Unread-Messages.js is a lightweight library that lets a user add mobile-like notification counter badge to any object with just one wrapper.

Install

NPM

npm

To install this package with NPM run the command below and link the needed javascript and css into your html file.

npm i unreadmessages --save

Direct Download

To use this package you need to link the needed javascript and css into your html file.

  <link rel="stylesheet" href="/src/css/style.css">

Because the library looks over the the page content for specific classes, place the script tag at the bottom of your HTML file or add the defer keyword to the tag, so the script will load after the HTML content.

  <script src="/src/js/main.js"></script>

Tutorial

Include the main css file a and javascript file. To initiate the, library two things are required, first a class of notification-container needs to be added to a wrapper element and the val data attribute needs to be defined inside of that element and you're done. If the data attribute is left empty it the displayed value will default to 0. To better illustrate the use of the library we'll be using FontAwesome icons as content for the wrappers.

  <div class="notification-container" data-val="">
        <i class="fas fa-bell" style="font-size: 45px;"></i>
  </div>

Material Bread logo

To fit the values with a reasonable size any value above 999 is displayed in a short-hand form. The displayed numbers shorthand follows the following convention

  • Any count 1000 and over like 1800 will be formated as 1.8k

  • Any value 1000000 and over like 1200,000 will be displayed as 1.2M

API

In addition to the data-val data attribute there are other attributes that can be used to further customize the badge.

Position

The position of the badge can be changed using the data-pos data attribute. If this attribute is not defined the badge position will default to top-right.

  <div class="notification-container" data-val="5" data-pos="bottom-left">
      <i class="fas fa-bell" style="font-size: 45px;"></i>
  </div>

Material Bread logo

Supported Positions

Position Tags
Top top
Top Right top-right
Top Left top-left
Bottom bottom
Bottom Right bottom-right
Bottom Left bottom-left

Color

You can also change the colors of the number tags by simply adding a data-val data attribute to your wrapper. Any color css-supported color name works as well as RGB values. If this attribute is not defined the badge will default to red.

  <div class="notification-container" data-val="5" data-color="blue">
    <i class="fas fa-bell" style="font-size: 45px;"></i>
  </div>

Material Bread logo

Hide After Click

You can decide how you want the badge to persist after mouse clicks by using the data-select-hide data attribute by default it is set to true but it can optionally explicitly set data-select-hide="false". This data attribute can also be set to false or False if you want the badge to persist after mouse clicks.

<div class="notification-container" data-val="5" data-select-hide="false">
    <i class="fas fa-bell" style="font-size: 45px;"></i>
  </div>

You will find that after setting the data-select-hide attribute to false, you will no longer be able to dismiss the displayed tag with a mouse click.

You might also like...

A chat logs online saver for discord bots to save messages history & cleared messages online

A chat logs online saver for discord bots to save messages history & cleared messages online

Chat Logs NPM package that saves messages online to view it later Useful for bots where users can save messages history & cleared messages online Supp

Dec 28, 2022

Input with floating label make with tailwindcss 3.0.18

Input with floating label make with tailwindcss 3.0.18

tailwind-floating-label-input Input with floating label make with tailwindcss 3.0.18 Works with input and textarea elements. How to use Input

Feb 10, 2022

Svelte✨ Floating UI 🎈

🎈 Svelte Floating UI Floating UI for Svelte with actions. No wrapper components or component bindings required! npm i -D svelte-floating-ui Usage cre

Dec 24, 2022

useOverlay uses floating-ui and framer-moting under the hood, giving you an API that provides great usability.

Create floating things easily useOverlay uses floating-ui and framer-moting under the hood, giving you an API that provides great usability. Warning D

Oct 24, 2022

Bootstrap 5 Floating Label

Bootstrap 5 Floating Label

@tkrotoff/bootstrap-floating-label Floating label for Bootstrap 5 Example: https://codesandbox.io/s/github/tkrotoff/bootstrap-floating-label/tree/code

Dec 10, 2022

Show floating sticky outline (table of contents) for Notion pages, powered by nbundle.

Notion Outline Show floating sticky outline (table of contents) for Notion pages, powered by nbundle. This is an nbundle-powered Notion app bootstrapp

Nov 10, 2022

AweSome Book App displays the book details entered by user and saves the information in Local storage. User can add and remove a book title/author to the library and from the library.

Awesome Book App with ES6 Used npm init -y command to create package.json file. Created the entry point for the JavaScript code called index.js Create

Aug 15, 2022

Calculating Pi number without limitation until 10k digits or more in your browser powered by JS without any third party library!

Calculating Pi number without limitation until 10k digits or more in your browser powered by JS without any third party library!

PI Calculator Web JS (Online) Calculating Pi number without limitation until 10k digits or more in your browser powered by JS without any third party

Jul 27, 2022

An online library for adding and removing a different number of books from a user collection, keeping track of the books you've read and the one's you are yet to read

An online library for adding and removing a different number of books from a user collection, keeping track of the books you've read and the one's you are yet to read

Awesmoe Books A Website demo for our project of book store, The website has ability of adding and removing you books from yor library, Thats reflects

Jul 8, 2022
Owner
Mulaza Jacinto
Frontend Web Developer ⚡️💻⚡️
Mulaza Jacinto
Displaying actual age in percentage with 9 signs after dot (floating number)

Actual Age Chrome Extension Displaying actual age in percentage with 9 signs after dot (floating number) Features Popup You can select your Birth date

Igor Makeenko 22 Nov 2, 2022
jquery-input-mask-phone-number.js - A simple, easy jquery format phone number mask library

jquery-input-mask-phone-number A jQuery Plugin to make masks on input field to US phone format. Quick start 1. Add latest jQuery and jquery-input-mask

Raja Rama Mohan Thavalam 12 Aug 25, 2022
Types generator will help user to create TS types from JSON. Just paste your single object JSON the Types generator will auto-generate the interfaces for you. You can give a name for the root object

Types generator Types generator is a utility tool that will help User to create TS Interfaces from JSON. All you have to do is paste your single objec

Vineeth.TR 16 Dec 6, 2022
Multiplies a number by zero. Useful for when you need to multiply a number by zero

multiply-by-zero Multiplies a number by zero. Useful for when you need to multiply a number by zero Please consider checking out the links of this pro

Dheirya Tyagi 2 Jul 3, 2022
A to-do list Web application that lets the user add, remove and reorder to do lists and checks a task when completed with a button to delete all completed task

TO DO LISTS A Web application that lets the user add, remove and reorder to do lists Built With Html,JS,CSS Webpack and other dependencies Git, Github

Promise Okechukwu 14 Nov 1, 2022
Formats message strings with number, date, plural, and select placeholders to create localized messages

Formats message strings with number, date, plural, and select placeholders to create localized messages. Small. Between 700 bytes and 1.3 kilobytes (m

Marcis Bergmanis 35 Oct 30, 2022
A live instant messaging app that translates user messages into the other user's preferred language.

BabelFish Description BabelFish is an interactive multi-person chat app with built in live translation. It is created using the MERN stack (MongoDB, E

Jamel 3 Jul 18, 2022
A lightweight JavaScript library for creating snackbar & toaster notifications.

Notify.js Notify.js is a lightweight (2.3kb) utility library for creating snackbar and toaster notifications. Installation Download Notify.js via NPM:

Kyle Andrews 7 Feb 13, 2022
Lets you add a character to Hacker News links to add social media and OpenGraph previews for sharing on things like Slack or Twitter.

news.ycombinator1.com Lets you add a character to Hacker News links to add social media and OpenGraph previews for sharing on things like Slack or Dis

Ian Langworth ☠ 38 Sep 18, 2022