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

@pavel-yakovlev/dropdown-menu

v1.1.2

Published

*** This is a JavaScript implementation of a simple dropdown with simple default style. If you want your dropdown to look good, please add some styles for it. *** ## Usage example

Readme

simpleDropdown


This is a JavaScript implementation of a simple dropdown with simple default style. If you want your dropdown to look good, please add some styles for it.


Usage example

Your html:

<!-- Only a body element for simplicity -->
<body>
  <div class="container">
    
  </div>
</body>

Your JS:

import SimpleDropdown from "simpleDropdown";

const dropdown = new SimpleDropdown(".container", "title");

dropdown
  .addItems(
    { content: "item1" },
    { content: "item2" },
    {
      content: "<b>item4</b>",
      style: {
        backgroundColor: "yellow",
      },
    },
  )
  .appendToContainer()
  .alignTitleAndItemsWidth()
  .showOnHover()
  .showOnClick();

Structure of the generated HTML element

<div class="sdd">
  <div class="sdd__title">
    Dropdown title
  </div>
  <div class="sdd__items">
    <div class="sdd__item">
      <div class="sdd__item-title">
        Item title
      </div>
    </div>
    <!-- Below there will be other items that you added -->
  </div>
</div>

Note that you can add custom classes throw the library API.


SimpleDropdown class API

new SimpleDropdown(containerSelector, titleContent, [styles])

A constructor. You must pass a selector for a container of this dropdown and a title. Optionally you can pass an object with styles that will be applied to the whole dropdown or to the items.

| Param | Type | Description | | --- | --- | --- | | containerSelector | string | selector for a container of this dropdown. | | titleContent | string | title of the dropdown. | | [styles] | dropdownStyles | styles for the dropdown and/or its items. |

simpleDropdown.childItems

Returns an array with child items. You can change a style of an individual item or add an event listener to it.

Kind: instance property of SimpleDropdown

simpleDropdown.appendToContainer() ⇒

Appends this dropdown element to its container on the page.

Kind: instance method of SimpleDropdown Returns: this. Throws:

  • Will throw an error if the container will not be selected.

simpleDropdown.addItems(...itemInfo) ⇒

Adds items to this dropdown.

Kind: instance method of SimpleDropdown Returns: this.

| Param | Type | Description | | --- | --- | --- | | ...itemInfo | itemOptions | an object with information for an item creation. |

simpleDropdown.addStyles(stylesToAdd) ⇒

Adds styles to this dropdown and/or its items.

Kind: instance method of SimpleDropdown Returns: this.

| Param | Type | Description | | --- | --- | --- | | stylesToAdd | dropdownStyles | object with styles that will be applied. |

simpleDropdown.alignTitleAndItemsWidth() ⇒

Aligns title and items widths. A maximal value will be applied.

Kind: instance method of SimpleDropdown Returns: this.

simpleDropdown.showOnHover() ⇒

Shows this dropdown items when hovering under it.

Kind: instance method of SimpleDropdown Returns: this.

simpleDropdown.showOnClick() ⇒

Shows this dropdown items when user clicks on the title.

Kind: instance method of SimpleDropdown Returns: this.