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 🙏

© 2025 – Pkg Stats / Ryan Hefner

custom-multi-or-simple-select

v1.0.118

Published

Custom select with search, multiple select and create

Readme

Custom Select Component

A customizable and easy-to-use React select component built with TypeScript and following the Atomic Design pattern.

Features

  • Single and multi-select options
  • Search and filter options
  • Option grouping
  • Create new options
  • Select/deselect all options

Installation

Install the package using npm:

npm install custom-multi-or-simple-select

Usage

Import the CustomSelect component from the package:

import { CustomSelect } from 'custom-multi-or-simple-select';

Import the default styles:

import "custom-multi-or-simple-select/dist/styles/CustomSelect.css";

Use the CustomSelect component in your React application:

const [selectedOption, setSelectedOption] = useState<OptionObject[]>([]);

const handleSelectChange = (selectedOptions: OptionObject[]) => {
	setSelectedOption(selectedOptions);
};

<CustomSelect
    multiple={true}
    options={options}
    hasSelectAll={true}
    isCreatable={false}
    closeOnChange={false}
    onChange={handleSelectChange}
    isLoading={false}
    className=""
    classNameDropdown=""
    classNameOption=""
    placeholder="Select one or more options"
/>

Props

| Prop | Type | Default | Description | |-------------------|--------------------------|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | multiple | boolean | true | Whether multiple options can be selected. | | options | OptionObject[] | - | An array of option objects. Each object must have an id and a label, and may also have a group. | | hasSelectAll | boolean | true | Whether to display the "Select All" option. | | isCreatable | boolean | false | Allows the user to create new options if the search does not match any existing options. | | closeOnChange | boolean | - | Whether to close the dropdown when an option is selected (only applicable when multiple is false). | | onChange | function | - | A callback function called when the selected options change. The function receives an array of selected OptionObjects as its argument. | | isLoading | boolean | false | Whether the component should display a loading state. | | className | string | '' | A custom class name for the main CustomSelect component. | | classNameDropdown | string | '' | A custom class name for the dropdown containing the options. | | classNameOption | string | '' | A custom class name for the option elements. | | placeholder | string | "Select one or more options" | Placeholder text for the search bar when no options are selected. |

Types

| Type | Description | |------------------|-----------------------------------------------------------------------------------------------| | OptionObject | An object representing a selectable option. It must have an id (string) and a label (string), and may also have a group (string). | | CustomSelectProps| An object containing all the props for the CustomSelect component. See the props table for details on each property. | | AddNewOptionProps| An object containing the props for the AddNewOption component, including label (string), text (string), onClick (function), and className (string).| | OptionRowProps | An object containing the props for the OptionRow component, including option (OptionObject), selected (boolean), multiple (boolean), onClick (function), and className (string).| | SearchBarProps | An object containing the props for the SearchBar component, including value (string), onChange (function), className (string), and placeholder (string).|

Default Styles

| Class Name | Properties | |-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------| | CustomSelect | position: relative; | | dropdown | position: absolute; width: 100%; background: #fff; z-index: 99; border-radius: 5px; border: 2px solid #ccc; padding-left: 1%; max-height: 20vh; overflow-y: auto; | | group | margin-top: .25rem; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; | | group-options | padding-left: 1rem; | | select-all | display: flex; justify-content: flex-start; align-items: center; gap: .25rem; width: 100%; border-bottom: 2px solid #ccc; | | SearchBar | display: flex; flex-direction: row; align-items: center; justify-content: center; width: 100%; height: 100%; border-radius: 5px; border: 2px solid #ccc; padding-left: 1%; | | OptionRow | display: flex; justify-content: flex-start; align-items: center; gap: .25rem; | | AddNewOption | padding-left: 1%; |