Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

badgin

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

badgin

Badgin makes it easy to subtly notify the user that there is some new activity that might require their attention, or it can be used to indicate a small amount of information, such as an unread count.

  • 1.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
177K
decreased by-16.1%
Maintainers
1
Weekly downloads
 
Created
Source

Badgin

The Badging API is a new web platform API that allows installed web apps to set an application-wide badge, shown in an operating-system-specific place associated with the application (such as the shelf or home screen). The Badging API works on Windows, and macOS, in Chrome 81 or later. It has also been confirmed to work on Edge 84 or later. Support for Chrome OS is in development and will be available in a future release of Chrome. On Android, the Badging API is not supported. Instead, Android automatically shows a badge on app icon for the installed web app when there is an unread notification, just as for Android apps. Since this API is not available everywhere, badgin safely falls back to alternatives.

via badge

Currently, the native badge is only displayed if you install the web application to your home screen (view prerequisites). The screenshot shows the application in the dock of macOS.

via favicon

If the native badge is not available, the favicon will be used and a small badge will be added.

via title

If the favicon is not available, the badge will be added as a prefix to the title.

Demo

You can find a demo at https://jaulz.github.io/badgin/ where you can see the different options. If you want to see the native badge, you need to install the app to your home screen (check out the plus icon in the address bar).

Installation

The module can be installed by running:

yarn add --save badgin

Usage

Just use the library as following:

import badgin from 'badgin'

badgin.set(1) // set value
badgin.set() // set indicator only
badgin.clear()

Options

The following options can be used:

{
  method: 'Badging' | 'Favicon' | 'Title'
  favicon: {
    backgroundColor: string = '#424242'
    color: string = '#ffffff'
    indicator: string = '!'
    radius: number = 3
    size: number = 7
    horizontalMargin: number = 0
    verticalMargin: number = 0
    horizontalPadding: number = 1
    verticalPadding: number = 1
  }
  title: {
    indicator: string = '!'
  }
}

And you can use it like this:

badgin.set(1, {
  favicon: {
    width: 9,
    background: '#549A2F',
  },
})

License / Credits

MIT

This is a refactored fork of the original Tinycon library, Tinycon is released under the MIT license. Tinycon was inspired by Notificon.

FAQs

Package last updated on 19 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc