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

@codebundlesbyvik/simple-notifier

v3.1.1

Published

A fully featured yet easy to use & lightweight notification library.

Downloads

23

Readme

Simple Notifier

npm npm - downloads per week jsdelivr - hits per week

A fully featured yet easy to use & lightweight notification library.

Demo page (interactive)

Table of Contents

  1. Nice features
  2. Usage
  3. Browser support
  4. Instance options
  5. Methods
  6. Events
  7. Upgrading from 2.x.x
  8. License

Nice features

  • Show multiple notifications simultaneously, and/or
  • Hide older notifications before showing one or more new notifications.
  • Great accessibility.
  • Is a compact ES module.

Skip to Instance options to get a complete overview of all features!

Usage

For this example I assume the main JavaScript file is processed by a module bundler that can process CSS files.

# Install package from npm
npm install @codebundlesbyvik/simple-notifier

If you're not using a module bundler then:

For the example below I assume the main JavaScript file is processed by a module bundler.

/* style.css */
@import "@codebundlesbyvik/simple-notifier";
// index.js
import "./style.css";
import SimpleNotifier from "@codebundlesbyvik/simple-notifier";

const notifier = new SimpleNotifier();

// The following element is inserted as the first child of <body>:
// <div class="simple-notifier simple-notifier--position-y-start simple-notifier--position-x-center">
// </div>

const text = "This is an example notification.";
const variant = "success";

notifier.show(text, variant);

// Notification is shown for 4000 ms.

Browser support

Requires an ECMAScript 2022 (ES13) compatible browser. Practically speaking, all browsers released in 2021 and onwards are fully supported.

Instance options

JavaScript

All options listed in the 2 tables below may be provided in an object as parameter on instance creation.

| Property | Type | Default | Description | | :-------------------------- | :------------------------------------------------- | :----------------------- | :---------------------------------------------------------------------------- | | parentEl | HTMLElement | document.body | HTML element in which the instance's element will be inserted as first child. | | position | ["start" \| "end", "start" \| "center" \| "end"] | ["start", "center"] | Logical position in the HTML document to render the instance's HTML element. | | classNames | string[] | [] | Extra classes to add to the instance's HTML element. | | hideButtonElAriaLabelText | string | "Dismiss notification" | Text used as aria-label for the notification hide button. | | theme | "light" | "dark" | "auto" | "auto" | Force color theme. | | animations | false | "auto" | "auto" | Force animation preference. |

Options below may also be provided via NotificationOptions and if done so take preference.

| Property | Type | Default | Description | | :-------------- | :-------- | :------ | :------------------------------------------------------------------------------------------------------------------------- | | hideAfterTime | number | 4000 | Time in milliseconds after which .hide() is automatically called. Set to 0 to disable this behavior. | | hideOlder | boolean | false | Hide all currently shown notifications before showing the next. | | dismissible | boolean | false | Render a close button which if pressed calls .hide(). |

CSS

| Variable name | Type | Default | Description | | :---------------------------------------- | :---------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------- |:----------------------------------------------------------- | | --simple-notifier-z-index | <integer> | auto | 1090 | Z-index applied to the instance's HTML element. | | --simple-notifier-font-family | See font-family values | Native font stack | Font family used for all notification content. | | --simple-notifier-font-size | See font-size values | 1rem | Base font size by which all internal sizes are calculated. | | --simple-notifier-color-opacity | <alpha-value> | 0.9 | Opacity applied to all available colors. | | --simple-notifier-color-<name>-channels | <color> | White, grey, black, green, yellow & red (see /src/style.css for exact values) | Available colors. | | --simple-notifier-animation-duration | <time> | auto | 500ms | Animation duration applied to all transitions & animations. |

Methods

.show(textOrOptions, variant?)

Show a notification.

Parameters

| Parameter | Type | Description | | :-------------------------------- | :---------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | textOrOptions Required | string | string[] | NotificationOptions | Text to render as notification content or NotificationOptions. Text may be provided as a string or multiple strings in an array. Each string is set as innerHTML of a <p>. | | variant | See NotificationOptions below. | Colorway of notification to render. Appended as BEM modifier to notification class list. Takes preference over variant provided in NotificationOptions if both are provided. |

NotificationOptions

NotificationOptions always take preference over NotifierOptions.

Notifications are only shown if either text or title is defined.

| Property | Type | Default | Description | | :-------------- | :----------------------------------------------------------------- | :---------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | text | string | string[] | undefined | Text to render as notification content. May be provided as a string or multiple strings in an array. Each string is set as innerHTML of a <p>. | | title | string | [string, string] | undefined | Text to render as notification title. Set as innerHTML, of a <p> if provided as a string or of element of type of title[1] if provided as title[0]. | | variant | "default" | "success" | "warning" | "error" | string | "default" | Colorway of notification to render. Appended as BEM modifier to notification class list. Overwritten if variant is also provided as .show() parameter. | | hideAfterTime | number | 4000 | Time in milliseconds after which .hide() is automatically called. Set to 0 to disable this behavior. | | hideOlder | boolean | false | Hide all currently shown notifications before showing the next. | | dismissible | boolean | false | Render a close button which if pressed calls .hide(). |

.hide(id: number)

Hide a currently shown notification by its ID. An id can be retrieved via the event fired on the instance element on notification show or the data-notification-id attribute on the notification element.

.hideAll()

Hide all currently shown notifications.

.currentId

Get the current ID, i.e. the one that'll be used for the next notification.

.ids

Get the IDs of all currently shown notifications.

Events

Events are fired on the instance element .simple-notifier. The detail property contains the id of the notification it was fired for.

| Event | Fired after... | | :---------- | :--------------------------------- | | shown | Notification is shown. | | hidden | Notification is hidden. | | allhidden | Last shown notification is hidden. |

Upgrading from 2.x.x

The following changes are breaking:

  • Removed: instanceId
  • Renamed: notificationId > id. Effects getters & event detail.
  • Renamed: dismissable > dismissible
  • Changed: Use logical directional keywords instead of physical keywords, i.e. left > start.
  • Changed: notificationOptions.titleLevel must now be provided as notificationOptions.title.el (see NotificationOptions).
  • Changed: If variant is provided both as .show() parameter and as notificationOptions.variant, .show() now takes preference.
  • Changed: Undocumented but public class field names, visibility & mutability.

License

Mozilla Public License 2.0 © 2025 Viktor Chin-Kon-Sung