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

t-aria-badge

v1.1.5

Published

HTML, CSS and JS badge UI-component for scalable projects

Readme

BADGE

About

HTML, CSS and JS badge UI-component for scalable projects. Go to demo page or check on npm.

  • Developed following BEM methodology
  • User-friendly and accessible
  • Less than 2KB JS (minified)
  • JS plugin runs in strict mode
  • Compatible with UMD

Dependencies

jQuery

Developed and tested with jQuery 3.2.1

Settings / Options

Name | Default | Type | Description -----|---------|------|------------- updatedClass | badge_updated | string | The class added to the badge when a value update occurs. updatedClassRemoveAfter | 3000 | int > 0 | Remove the updatedClass after the time passed. hiddenClass | badge_hidden | string | The class added to the badge when hideWhenZero is set to true and the badge's value is 0, null, undefined or false. aLabel | You have {X} notifications | string | The accessible label for the badge ({X} will be replaced with the value passed with initialValue or to the method update). useTitle | true | bool | Use the accessible label also as title attribute. initialValue | 0 | string or int | Initial value of the badge. hideWhenZero | false | bool | When true the badge will be hidden by adding the hiddenClass and setting aria-hidden="true" when the badge's value is 0, null, undefined or false.

Installation

Download the package from GitHub and get the compiled files from the dist folder.

The plugin is also available on npm:

npm install t-aria-badge

Usage

  1. Include the JS script badge.js - or the minified production script badge.min.js- in the head or the body of your HTML file.
  2. Include the CSS file badge.css in the head of your HTML file or include the SCSS files in your project.
  3. Initialise the widget within an inline script tag, or in an external JS file.

HTML

Use following HTML markup to implement a badge:

<span class="badge"></span>

IMPORTANT: If a region of the page is responsible for the update of the badge, it is necessary to expose the relation between the badge and the page region with the aria-controls attribute for accessibility.

JS: Initialise

Initialise the plugin as follows:

$('.badge').badge({
  option1: value1,
  option2: value2
});

Methods

The plugin supports following methods: update.

Update:

To update a badge call badge and pass 'update' as first parameter and the new value as second parameter:

$('#my-badge').badge('update', 10);

Custom events

This plugin triggers following events:

  • badge.initialised after the badge is initialised.
  • badge.updated when the badge is updated.

The custom events are triggered on window and return the badge data object as argument.

//add event listener  
$(window).on('badge.initialised', function(event, badge){
  //perform an action
  badge.element.addClass('my-custom-class');
});

LICENSE

This project is licensed under the terms of the MIT license.

See LICENSE.md for detailed informations.