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

vanilla-snackbar

v1.0.1

Published

A full width snackbar using "vanilla js"

Readme

Snackbar.js (Vanilla-Snackbar)

A simple implementation of a full width snackbar message using "vanilla js".
View exmple at http://chrisdimoulis.com/snackbar.js

Changelog

npm node deps tests coverage

Production Dependencies

None! (not even jquery)

Installation

Node

npm install --save vanilla-snackbar

Usage

Importing/Including

Node

Import vanilla-snackbar into your module:

import Snackbar from 'vanilla-snackbar';

Style

See src/snackbar.scss for default style and reference if you desire to override any styles.

Pre DOM ready

If you create a snackbar and create a message before the DOM is ready the message will be stored in a queue which which will execute once the DOM is ready.

Create Snackbar

  // New snackbar with defaults
  var default_snack = new Snackbar();

  // New snackbar with custom default time
  var short_snack = new Snackbar({time: 2000});

  // New snackbar where the default behviour is to manually close
  var manual_snack = new Snackbar({manual_close: true});

All options passed when creating the snackbar object are default. Overrides can be passed in each call to display a message.

Available Options

  • manual_close: Boolean. Provide a close X button (true) vs timed close (false). Default: false
  • time: ms of time before automatic close. (ignored if manual_close: true). Default: 5000
  • class: String containing desired classes to add to snackbar. Default: empty

NOTE: Default Options and Multiple Snackbar Objects

A new Snackbar object will not inject new #snackbar-wrapper elements. All Snackbar objects use the same wrapper. It simply creates a new object with a different set of default options for displaying a Snackbar message. See below for overriding default options on a message specific basis as opposed to creating multiple Snackbar objects.

Displaying Messages

Displaying a message is as simple as calling the .message(msg, opts) function of the Snackbar. There are also four helper methods for common Snackbar usage. All of these functions take 2 parameters:

  • msg: the message to be displayed.
  • opts: the options to override default options.
  // Display a message
  snack.message('Hello World');

  // Helper functions:
  // Display a message that must be removed manually ->
  snack.stickyMessage('Acknowledge me!');
  // Display a message with a green background (adds class 'success') ->
  snack.success('You did it!');
  // Display a message with a red background (adds class 'error') ->
  snack.error("Something didn't work");
  // Display a message with a orangish/yellow background (adds class 'warn') ->
  snack.warn("I'd be careful if I were you...");

Creating a Snackbar message will return a Promise object. This promise object will resolve when the Snackbar has finished fading in.

Overriding Default Options

  // New snackbar with defaults
  var snack = new Snackbar();
  // Require user to close message just this one time
  snack.message('Read this', {manual_close: true})

  // New snackbar with custom default time
  var snack = new Snackbar({time: 2000});
  // Make this message stick longer than default
  snack.message("A slightly longer message..."), {time: 7500});
  // Add your own classes to the snackbar
  snack.message("My special snackbar", {class: 'my-snackbar your-snackbar'})