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

think-custom-select

v1.0.0

Published

A JavaScript class that transforms standard HTML <select> elements into customizable dropdown UIs.

Readme

CustomSelect Component

Overview

The CustomSelect component is a JavaScript class that transforms standard HTML <select> elements into customizable dropdown UIs. This component enhances the visual appearance and functionality of select menus without altering their underlying behavior.

Usage

Step 1: Import Required Files

First, ensure you have imported both the JavaScript and SCSS files in your project:

// Import CustomSelect class
import CustomSelect from './CustomSelect.js';

// Import custom styles
import './custom-select.scss';

Step 2: Initialize CustomSelect

Create an instance of CustomSelect by passing a CSS selector string that targets the <select> elements you want to customize:

document.addEventListener('DOMContentLoaded', () => {
    const customSelect = new CustomSelect('.my-select-class');
});

Replace .my-select-class with the appropriate class or ID of your select elements.

Features

Custom Appearance

The component provides a customizable dropdown UI with styles for:

  • Selected options
  • Disabled options
  • Dropdown visibility
  • Scrollbars

Functionality

  • Label Update: Automatically updates the label text to reflect the selected option.
  • Dropdown Toggle: Toggles the dropdown list when the label is clicked.
  • Option Selection: Updates both the custom UI and the original <select> element when an option is chosen.
  • Outside Click Close: Closes the dropdown when clicking outside of it.

Example

Here's a simple example of how to use the CustomSelect component:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="path/to/custom-select.scss">
    <title>CustomSelect Example</title>
</head>
<body>
    <select class="my-select-class">
        <option value="1">Option 1</option>
        <option value="2">Option 2</option>
        <option value="3" disabled>Disabled Option</option>
    </select>

    <script type="module">
        // Import CustomSelect class
        import CustomSelect from './CustomSelect.js';

        document.addEventListener('DOMContentLoaded', () => {
            const customSelect = new CustomSelect('.my-select-class');
        });
    </script>
</body>
</html>

In this example, the CustomSelect component is initialized on a select element with the class .my-select-class, enhancing its appearance and functionality as described.

Notes

  • Ensure that the paths to your SCSS and JavaScript files are correct.
  • Customize the styles in custom-select.scss to match your design requirements.