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

searchable-select-js

v0.0.1

Published

A lightweight, dependency-free searchable select component that enhances native HTML select elements.

Readme

Searchable Select

A lightweight, dependency-free searchable select component that progressively enhances native HTML <select> elements.

Features

  • Progressive Enhancement - Works with native HTML selects
  • Zero Dependencies - Pure vanilla JavaScript
  • Single & Multiple Selection - Automatic detection via multiple attribute
  • Server-Side Search - Built-in AJAX support with debouncing
  • Keyboard Accessible - Full keyboard navigation support
  • Form Compatible - Native form submission with proper name attribute
  • Lightweight - < 10KB minified

Installation

npm install searchable-select

Usage

Basic Setup

<!-- Include CSS -->
<link rel="stylesheet" href="node_modules/searchable-select/dist/searchable-select.min.css">

<!-- Your HTML -->
<select name="fruit" data-placeholder="Choose a fruit...">
    <option value="">Select...</option>
    <option value="apple">Apple</option>
    <option value="banana">Banana</option>
    <option value="cherry">Cherry</option>
</select>

<!-- Include JS -->
<script src="node_modules/searchable-select/dist/searchable-select.min.js"></script>
<script>
    // Initialize all selects
    SearchableSelect.autoInit();
</script>

With Module Bundler

import SearchableSelect from 'searchable-select';
import 'searchable-select/dist/searchable-select.css';

// Auto-initialize all selects
SearchableSelect.autoInit();

// Or initialize specific select
const mySelect = document.querySelector('#my-select');
new SearchableSelect(mySelect);

Auto-Initialize

Add data-auto-init attribute to your HTML:

<html data-auto-init="searchable-select">
    <!-- Your selects will be automatically initialized -->
</html>

Configuration

All configuration is done via data-* attributes on your <select> element:

| Attribute | Description | Default | |-----------|-------------|---------| | data-placeholder | Placeholder text | "Select an option..." | | data-search-placeholder | Search input placeholder | "Search..." | | data-search-url | URL for server-side search | null | | data-search-delay | Debounce delay in ms | 300 | | data-loading-text | Loading message | "Loading..." | | data-no-results-text | No results message | "No results found" |

Examples

Single Select

<select name="country" data-placeholder="Choose a country...">
    <option value="">Select...</option>
    <option value="us">United States</option>
    <option value="uk">United Kingdom</option>
    <option value="ca">Canada</option>
</select>

Multiple Select

<select name="colors[]" 
        multiple 
        data-placeholder="Choose colors...">
    <option value="red">Red</option>
    <option value="blue">Blue</option>
    <option value="green">Green</option>
</select>

Server-Side Search

<select name="user" 
        data-placeholder="Search users..."
        data-search-url="/api/users/search"
        data-search-delay="500">
    <option value="">Start typing...</option>
</select>

Server Response Format:

[
    { "value": "1", "label": "John Doe" },
    { "value": "2", "label": "Jane Smith" }
]

Pre-selected Values

<select name="size">
    <option value="">Select...</option>
    <option value="s">Small</option>
    <option value="m" selected>Medium</option>
    <option value="l">Large</option>
</select>

Disabled Options

<select name="product">
    <option value="">Select...</option>
    <option value="item1">Available Item</option>
    <option value="item2" disabled>Out of Stock</option>
</select>

API

Methods

const select = document.querySelector('#my-select');
const instance = new SearchableSelect(select);

// Refresh the component (after adding/removing options)
instance.refresh();

// Destroy the component
instance.destroy();

// Access the instance from the select element
select.searchableSelect.refresh();

Static Methods

// Initialize all selects on the page
SearchableSelect.autoInit();

// Initialize specific selects
SearchableSelect.autoInit('select.custom-class');

🗺️ Roadmap

  • [ ] Accessibility
  • [ ] Keyboard navigation
  • [ ] TypeScript support
  • [ ] Right-to-left (RTL) support

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

License

MIT

Contributing

Contributions are welcome! Please open an issue or submit a pull request.