npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

electron-taskbar-badge

v2.0.0

Published

An easy way for electron apps to add app badges to the taskbar to indicate notifications, status, or countable items, with maximum compatibility and customizability.

Readme

versionweekly_downloadsdownloadsissueslicenseelectron-taskbar-badge

Electron Taskbar Badge

An easy way for electron apps to add app badges to the taskbar to indicate notifications, status, or countable items, with maximum compatibility and customizability.


Changelog (v2.0.0)

• [BREAKING]: Rename additionalFunc to onBadgeUpdate for clarity purposes. This is simply a name change.
• Font and radius is no longer a configurable option.
• Improve text fitting in badge icon. (this removes the fit option)
• Add new badge types: activity, alarm, alert, attention, error, available, busy, away, unavailable, newMessage, paused, playing.
• Negative numbers and all falsy values now clear the badge icon.
• Improve badge text centering.
• Migrate source to TypeScript.
• Expose update() as a public method on the Badge instance.


Installation

npm i electron-taskbar-badge

Basic Usage

This library only supports Windows at the moment!

First, you must import the library using the following code:

const Badge = require('electron-taskbar-badge');
// or `import * as Badge from 'electron-taskbar-badge';` for ESM users


For basic usage, all you have to do is call the function with the options:

Process: Main

const Badge = require('electron-taskbar-badge');
// or `import * as Badge from 'electron-taskbar-badge';` for ESM users

const badgeOptions = {
	fontColor: '#FFFFFF', // The font color
	color: '#FF0000', // The background color
	updateBadgeEvent: 'notificationCount', // The IPC event name to listen on
	badgeDescription: 'Unread Notifications', // The badge description
	invokeType: 'handle', // The IPC event type
	max: 9, // The maximum integer allowed for the badge. Anything above this will have "+" added to the end of it.
	onBadgeUpdate: (count) => {
		// Called whenever the badge is updated. count is the value set (number, badge type string, or null when cleared).
		console.log(`Badge updated: ${count}`);
	},
};

// "win" would be your Electron BrowserWindow object
new Badge(win, badgeOptions);

Process: Renderer

// If invokeType is set to "handle"
// Replace 8 with whatever number or badge type you want the badge to display
ipcRenderer.invoke('notificationCount', 8);

// If invokeType is set to "send"
ipcRenderer.send('notificationCount', 8);

To clear the badge, simply pass a falsy value or a negative integer.

That's it! Now you have it running!

More examples

Badge types

Instead of a number, you can pass one of the following string values to display a glyph badge:

| Type | Icon | Description | |------|------|-------------| | activity | 🔄 | Activity indicator | | alarm | 🕭 | Alarm indicator | | alert | ! | Alert indicator | | attention | ✱ | Attention indicator | | error | ✕ | Error indicator | | available | 🟢 | Available / online status | | busy | 🔴 | Busy / occupied status | | away | 🟡 | Away / idle status | | unavailable | ⚪ | Unavailable / offline status | | newMessage | ✉ | New message indicator | | paused | ⏸ | Paused status | | playing | ▶ | Playing / active playback |

*Emoji's are an approximate representation. See https://learn.microsoft.com/en-us/windows/apps/develop/notifications/badges for a more accurate visual.

// From the renderer
ipcRenderer.invoke('notificationCount', 'alert');

// Or directly from the main process
const badge = new Badge(win, badgeOptions);
badge.update('available');

Native look

If you want your badge to look native to the operating system, which means that it follows the default OS's font and color, you can use the useSystemAccentTheme option. Here's an example:

// When useSystemAccentTheme is true, the background color would be the system accent color, and the font color would be automatically chosen between black or white, which ever looks best.
const badgeOptions = {
	updateBadgeEvent: 'notificationCount',
	badgeDescription: 'Unread Notifications',
	invokeType: 'handle',
	max: 9,
	useSystemAccentTheme: true,
	onBadgeUpdate: (count) => {
		console.log(`Received ${count} new notifications!`);
	},
};

new Badge(win, badgeOptions);

Examples

Taskbar Badge Purple
Taskbar Badge Blue
Taskbar Badge Green

Auto font color

If you want your badge's font color to be automatically chosen, simply set fontColor to auto. This will choose the font color between black or white, whichever looks best. Here's an example:

const badgeOptions = {
	fontColor: 'auto',
	color: '#00FF00',
	updateBadgeEvent: 'notificationCount',
	badgeDescription: 'Unread Notifications',
	invokeType: 'handle',
	max: 9,
	onBadgeUpdate: (count) => {
		console.log(`Received ${count} new notifications!`);
	},
};

new Badge(win, badgeOptions);

Options

Options info for Badge(options)

| Parameters | Type | Description | Default | |---------------|---------|----------------------------------------|---------| | fontColor | string | The font color in hex or RGB color format. When useSystemAccentTheme is true, this is always set to auto. | auto | | color | string (required) | The background color for the badge icon in hex or RGB color format. When useSystemAccentTheme is true, this is ignored. | null | | updateBadgeEvent | string (required) | The IPC event name to listen on | null | | badgeDescription | string | A description that will be provided to accessibility screen readers | this.updateBadgeEvent | | invokeType | string | The IPC event type. Can be send or handle. | send | | max | number | The maximum integer allowed for the badge. Anything above this will have "+" added to the end of it. | 9 | | useSystemAccentTheme | boolean | Whether to use the system accent color for the background color. fontColor and color will be overridden. It would be automatically chosen between black or white, whichever looks best. | false | | onBadgeUpdate | function(count: number | BadgeType | null) | An additional function to run whenever the IPC event fires. Receives the value the badge was set to, or null when cleared. | null |