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

@dcdavidev/vanilla-sidenav

v3.2.0

Published

A simple side nav

Downloads

50

Readme

@dcdavidev/vanilla-sidenav

A lightweight, high-performance side navigation library written in pure vanilla JavaScript. With zero dependencies, it provides a smooth, native-like mobile sidebar experience while maintaining a tiny footprint.

Features

  • 🚀 Zero Dependencies: Pure JavaScript, no jQuery or other libraries required.
  • High Performance: Optimized animations using CSS3 transitions.
  • 🧊 Page Freezing: Automatically prevents background scrolling when the menu is active.
  • 🎭 Smart Masking: Generates a clickable background overlay to dim the page content.
  • ⌨️ TypeScript First: Written in TypeScript with full type definitions included.

Installation

# pnpm
pnpm add @dcdavidev/vanilla-sidenav

# npm
npm install @dcdavidev/vanilla-sidenav

# yarn
yarn add @dcdavidev/vanilla-sidenav

Quick Start

1. HTML Structure

Your template requires a trigger element and the sidenav container.

<!-- Trigger -->
<header>
  <button id="toggle-sidenav">Open Menu</button>
</header>

<!-- Sidenav -->
<nav id="sidenav">
  <div class="sidenav-wrapper">
    <button class="quit-sidenav">Close</button>
    <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">Products</a></li>
      <li><a href="#">Services</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
  </div>
</nav>

2. Basic Initialization

Import the class and initialize it with your selectors:

import { Sidenav } from '@dcdavidev/vanilla-sidenav';

const sidenav = new Sidenav({
  selector: '#sidenav',
  triggerer: '#toggle-sidenav',
  quitter: '.quit-sidenav'
});

Advanced Usage

Handling Content Overflow

For long menus that require scrolling, add the following CSS to your wrapper element:

#sidenav .sidenav-wrapper {
  height: 100%;
  overflow-y: auto;
}

Manual Control

You can also control the sidenav programmatically:

const sidenav = new Sidenav({ ... });

// Open the menu
sidenav.open();

// Close the menu
sidenav.close();

Options

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | selector | string | '#sidenav' | The CSS selector for your sidenav container. | | triggerer | string | Required | The CSS selector for the element that toggles the menu. | | quitter | string | Required | Selector for elements inside the menu that close it when clicked. | | align | 'left' \| 'right' | 'left' | Which side the sidenav should appear on. | | width | string | '300px' | The width of the sidenav (with unit). | | gap | number | 56 | Minimum distance from the screen edge on small screens (in pixels). | | top | string | '56px' | The top offset of the sidenav. | | opened | boolean | false | Whether the sidenav starts open. | | mask | boolean | true | Enable/disable the background mask. | | easing | string | 'ease-in-out' | CSS transition timing function. | | zIndex | number | 3000 | The z-index of the sidenav element. |

License

MIT © Davide Di Criscito