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

searchdown

v1.0.9

Published

A searchable dropdown/select component with tagging support

Readme

Searchdown

A searchable dropdown/select component with tagging and multi-select support.

Demo

Here's a demo

Installation

npm install searchdown

Usage

ES6 Modules (Recommended)

import searchdown, {getValue, setValue, validate} from 'dist/searchdown';
import 'searchdown/styles'; // Import CSS

// Initialize on an element
searchdown('#my-dropdown', {
    values: ['Apple', 'Banana', 'Cherry', 'Date'],
    placeholder: 'Select a fruit...',
    multiple: true
});

// Get selected values
const selected = getValue('#my-dropdown');

// Set values programmatically
setValue('#my-dropdown', ['Apple', 'Cherry']);

CommonJS

const {searchdown, getValue, setValue} = require('dist/searchdown');

Browser (UMD)

<script src="https://unpkg.com/searchdown/dist/searchdown.umd.js"></script>
<link rel="stylesheet" href="https://unpkg.com/searchdown/dist/searchdown.css">

<script>
    Searchdown.searchdown('#my-dropdown', { values: ['A', 'B', 'C'] });
</script>

Options

| Option | Type | Default | Description | |-------------------|------------------------|-------------|--------------------------------------------------------------------------------------------------------------------------------| | values | string[] or object | [] | Available options to select from | | sort | 'ASC' | 'DESC' | undefined | Sort order for dropdown options | | limit | number | 0 | Max options to show (0 = unlimited) | | enteredLimit | number | 0 | Max selections allowed (0 = unlimited) | | multiple | boolean | false | Allow multiple selections | | addValues | boolean | false | Allow adding custom values | | saveEntered | boolean | false | Save custom values to options list | | hideEntered | boolean | false | Hide already-selected options | | allowDuplicates | boolean | false | Allow duplicate selections | | caseSensitive | boolean | false | Case-sensitive search | | placeholder | string | 'Search' | Input placeholder text | | required | number | boolean | 0 | Minimum required selections | | maxHeight | number | 600 | Max dropdown height in pixels | | inputName | string | auto | Form input name attribute | | initialValues | string[] | [] | Pre-selected values | | simpleInput | boolean | false | Single input mode (no tags) | | textarea | boolean | false | Use textarea instead of input | | onChange | function | null | Provide a function which is called whenever the selected options are changed. Takes two arguments: (element, value) => { ... } |

Color Options

| Option | Description | |---------------------|--------------------------| | baseBackColor | Background color | | selectedBackColor | Selected item background | | hoverBackColor | Hover background | | baseTextColor | Text color | | selectedTextColor | Selected item text color | | hoverTextColor | Hover text color |

API

searchdown(element, options)

Initialize a searchdown instance.

getValue(element, includeNotEntered?)

Get the selected value(s). Returns a string for single-select or array for multi-select.

setValue(element, values)

Set the selected value(s) programmatically.

validate(element)

Validate the element and return validity status.

reportValidity(element)

Validate and show browser validation UI.

autoCreate()

Auto-initialize all elements with class="searchdown" and data-sd_* attributes.

enableAutoCreate()

Enable automatic initialization on DOMContentLoaded.

setMessageHandler(handler)

Set a custom message handler for all searchdown instances. By default, messages are shown using alert().

import { setMessageHandler } from 'dist/searchdown';

// Use with Toastify
setMessageHandler((text, type) => {
  Toastify({ 
    text, 
    type,  // "success" or "error"
    duration: 5000,
    gravity: "top",
    position: "center"
  }).showToast();
});

// Use with a custom notification system
setMessageHandler((text, type) => {
  myNotificationSystem.show(text, { type: type });
});

// Reset to default (alert)
setMessageHandler(null);

Parameters:

  • handler - A function that receives (text, type) where type is either "success" or "error". Pass null to reset to the default alert() behavior.

Auto-Creation via Data Attributes


<div class="searchdown"
     data-sd_values='["Option 1", "Option 2", "Option 3"]'
     data-sd_multiple="true"
     data-sd_placeholder="Choose options...">
</div>

<script type="module">
    import {enableAutoCreate} from 'dist/searchdown';

    enableAutoCreate();
</script>

License

MIT

Development

  1. Clone the repo
  2. npm install
  3. npm run dev
  4. Open test/test.html in your browser