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

ark-select-single

v0.0.4

Published

simple library to select single item

Readme

🎯 ark-select-single

npm version npm downloads jsDelivr hits license

ark-select-single is a zero‑dependency JavaScript library that turns any ordinary <select> element into a fully searchable dropdown. All styles are embedded – no external CSS files required. It also provides simple methods to dynamically add or remove options.


Demo Link

You may be using Demo Link.


✨ Features

  • 🔍 Live search/filter – type to narrow down options.
  • ⌨️ Keyboard navigation – arrow keys, Enter to select, Esc to close.
  • 🎨 Self‑styled – all CSS injected automatically.
  • 📦 Tiny footprint – no dependencies, just vanilla JS.
  • 🔧 Dynamic options – add/remove options after initialization.
  • 🧩 Framework‑agnostic – works with any project (React, Vue, plain HTML).

🚀 Installation

npm / yarn

npm install ark-select-single
# or
yarn add ark-select-single

---

### CDN (unpkg) – also allows direct file download
```html
<script src="https://cdn.jsdelivr.net/npm/ark-select-single@latest/ark-select-single.js"></script>

Note: The library is not available on cdnjs. Please use the jsDelivr or unpkg links above.
If you need a local copy, right‑click this link and select "Save link as…" to download the minified file.

The library is exposed globally as ArkSearchableSelect.


📖 Basic Usage

  1. Include the library (either via npm import or CDN script).
  2. Add a standard <select> element with some <option> children.
  3. Create a new instance by passing a CSS selector or DOM element.

Example

<select id="fruit-select">
  <option value="apple">Apple</option>
  <option value="banana">Banana</option>
  <option value="cherry">Cherry</option>
  <option value="date">Date</option>
</select>

<script src="https://cdn.jsdelivr.net/npm/ark-select-single@latest/ark-select-single.js"></script>
<script>
  new ArkSearchableSelect('#fruit-select');
</script>

That’s it! The original select is automatically hidden and its value stays in sync.

Demo screenshot


🧠 API Reference

Constructor

new ArkSearchableSelect(selector)
  • selector – a CSS selector string or a DOM element pointing to an existing <select>.

Methods

| Method | Description | |--------|-------------| | addOption(value, text, position) | Adds a new option. See Dynamic Options for details. | | removeOption(value) | Removes all options with the given value. |

Both methods automatically refresh the dropdown UI and keep the selected value consistent.


🔧 Dynamic Options

You can add or remove options at any time after initialization.

addOption(value, text, position)

  • value (string) – the option’s value attribute.
  • text (string) – the displayed text.
  • position (optional) – where to insert the new option. Can be:
    • A number (0‑based index) – inserts at that exact position.
    • 'last' – appends at the end (default).
    • 'alpha' – inserts in case‑insensitive alphabetical order based on the displayed text.

removeOption(value)

  • value (string) – removes every option whose value matches this string.
    If the currently selected option is removed, the first remaining option (if any) becomes selected.

Example

const mySelect = new ArkSearchableSelect('#my-select');

// Add options
mySelect.addOption('plum', 'Plum', 'last');      // append at the end
mySelect.addOption('apricot', 'Apricot', 'alpha'); // insert alphabetically
mySelect.addOption('kiwi', 'Kiwi', 2);             // insert at index 2

// Remove an option
mySelect.removeOption('banana');

Dynamic feature in the working recorded as gif

Demo screenshot


🎨 Styling

All necessary styles are injected by the library. If you want to override them, use the following CSS classes:

| Class | Element | |-------|---------| | .searchable-select-container | Outer wrapper | | .searchable-select-display | The box showing the selected value | | .searchable-select-dropdown | Dropdown panel | | .searchable-select-search | Search input inside the dropdown | | .searchable-select-options | <ul> containing options | | .searchable-select-option | Each option item | | .searchable-select-option.selected | Currently selected option | | .searchable-select-option.highlighted | Option highlighted via keyboard |

Example override

.searchable-select-container {
  max-width: 400px;
  font-family: 'Segoe UI', sans-serif;
}
.searchable-select-option.selected {
  background-color: #4f46e5;
  color: white;
}

🌐 Browser Support

Works in all modern browsers (Chrome, Firefox, Safari, Edge). Internet Explorer is not supported.


📄 License

MIT © [Immanuel R]


---

## 👤 Author

**Immanuel R**  
- Email: [[email protected]](mailto:[email protected])  
- GitHub: [@ir-dev](https://github.com/ir-dev)