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

@magic-spells/dropdown-panel

v0.2.2

Published

Accessible custom dropdown panel web component.

Readme

@magic-spells/dropdown-panel

A lightweight, accessible dropdown panel web component designed for modern web applications.

🔍 Live Demo - See it in action!

Features

  • 🪶 Lightweight and dependency-free
  • 🌈 Fully customizable with CSS variables
  • ⌨️ Keyboard accessible
  • ♿ WAI-ARIA compliant
  • 📱 Mobile-friendly

Installation

npm install @magic-spells/dropdown-panel

Usage

Import the component in your JavaScript:

// ESM import
import '@magic-spells/dropdown-panel';

// Or in HTML
<script src="node_modules/@magic-spells/dropdown-panel/dist/dropdown-panel.min.js"></script>
<link rel="stylesheet" href="node_modules/@magic-spells/dropdown-panel/dist/dropdown-panel.min.css">

Then use it in your HTML:

<dropdown-component>
  <dropdown-trigger>Menu</dropdown-trigger>
  <dropdown-panel>
    <a href="#" class="dropdown-item" role="menuitem">Option 1</a>
    <a href="#" class="dropdown-item" role="menuitem">Option 2</a>
    <div class="dropdown-divider"></div>
    <a href="#" class="dropdown-item" role="menuitem">Option 3</a>
  </dropdown-panel>
</dropdown-component>

For a larger "mega menu" style layout, use <dropdown-menu> instead of <dropdown-panel>:

<dropdown-component>
  <dropdown-trigger>Products</dropdown-trigger>
  <dropdown-menu>
    <div>
      <a href="#" class="dropdown-item" role="menuitem">Software</a>
      <a href="#" class="dropdown-item" role="menuitem">Hardware</a>
      <a href="#" class="dropdown-item" role="menuitem">Services</a>
    </div>
    <div>
      <a href="#" class="dropdown-item" role="menuitem">Support</a>
      <a href="#" class="dropdown-item" role="menuitem">Community</a>
      <a href="#" class="dropdown-item" role="menuitem">Partners</a>
    </div>
  </dropdown-menu>
</dropdown-component>

Component Types

This library provides two types of dropdown containers:

<dropdown-panel>

  • 🧩 Popover-style panel, great for short or simple option lists.
  • Appears as a smaller, compact dropdown.
  • Use when you need a small group of links or actions.

<dropdown-menu>

  • 🧩 Mega menu style, designed for larger, full-width menus.
  • Supports multiple columns inside the menu for richer layouts.
  • Use when you have multiple categories or larger navigation needs.

Both types are accessible, keyboard-friendly, and customizable!

Styling

The component uses CSS custom properties (variables) for easy customization:

:root {
  /* Panel appearance */
  --panel-bg-color: #ffffff;
  --panel-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  --panel-border-radius: 4px;
  --panel-padding: 0.5rem 0;
  --panel-margin-top: 0.25rem;

  /* Item styling */
  --item-padding: 0.5rem 1rem;
  --item-color: inherit;
  --item-hover-bg: #f0f5ff;

  /* Divider styling */
  --divider-color: #e9ecef;

  /* Animation */
  --transition-duration: 0.2s;
  --transition-timing: ease;
}

API

Components

  • <dropdown-component>: The main container that coordinates everything
  • <dropdown-trigger>: The element that toggles the dropdown open/close
  • <dropdown-panel>: A compact popover dropdown for smaller lists
  • <dropdown-menu>: A full-width, mega menu–style dropdown for large layouts

Methods

// Get reference to the component
const dropdown = document.querySelector('dropdown-component');

// Show the dropdown
dropdown.show();

// Hide the dropdown
dropdown.hide();

Events

The dropdown component is fully compatible with standard event listeners:

const dropdown = document.querySelector('dropdown-component');

dropdown.addEventListener('mouseleave', () => {
  // Do something when mouse leaves dropdown
});

Accessibility

This component follows WAI-ARIA practices for dropdown menus:

  • Proper ARIA roles, states, and properties
  • Keyboard navigation (Tab, Space, Enter, Escape)
  • Focus management
  • role="menuitem" added for screen readers

Browser Support

  • Chrome/Edge (latest)
  • Firefox (latest)
  • Safari (latest)
  • Other modern browsers that support Custom Elements v1

License

MIT