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

react-selector-multiple

v1.0.3

Published

multiple select component for react

Readme

react-selector-multiple

multiple_select

Installation

npm install --save react-selector-multiple

This library using react hooks. Note that to enable Hooks, all React packages need to be 16.8.0 or higher.

Prop Types

|Prop|Type|Description| |---|---|---| |options|arrayOf(object / string)|all option you want to show, if you want array of objects, the object should look like this {value: string / object, name: string}| |selectedValues|arrayOf(object / string)|need to set here the selected values, if the option is array of objects you get the value| |onChange|func|event that return the selected, also here if the option is array of objects you get the value| |style|oneOfType(object, array)|set different style to select tag| |selectedOptionStyle|oneOfType(object, array)|set different style to selected options| |placeHolder|string|change the place holder| |selectedPlaceHolder|func|allow to change the default string after select any item,can see in Example Code| |selectAllOptions|bool|add select all option|

Example Code

demo

import React, { useState } from 'react';
import MultipleSelect from 'react-selector-multiple';

const App = () => {
  const [values_1, setValues_1] = useState([]);
  const [values_2, setValues_2] = useState([]);
  const [values_3, setValues_3] = useState([]);

  const options_1 = [
    'Red',
    'Green',
    'Blue',
    'Yellow'
  ];

  const options_2 = [
    { value: 'Red', name: 'Red' },
    { value: 'Green', name: 'Green' },
    { value: 'Blue', name: 'Blue' },
    { value: 'Yellow', name: 'Yellow' }
  ];

  const options_3 = [
    { value: { id: 1 }, name: 'Red' },
    { value: { id: 2, value: 'green' }, name: 'Green' },
    { value: { id: 3, value: 'blue' }, name: 'Blue' },
    { value: { id: 4, value: 'yellow' }, name: 'Yellow' }
  ];

  return (
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
      <div>
        <h4>options_1 array of strings:</h4>
        <MultipleSelect
          options={options_1}
          selectedValues={values_1}
          onChange={e => setValues_1(e)}
          style={{ borderRadius: '5px', outline: 'none' }}
        />
      </div>

      <div>
        <h4>options_2 array of objects, the value is string:</h4>
        <MultipleSelect
          options={options_2}
          selectedValues={values_2}
          onChange={e => setValues_2(e)}
          style={{ borderRadius: '5px', outline: 'none' }}
          selectedOptionStyle={{ color: '#dc143c' }}
          placeHolder='Multiple Select'
          selectedPlaceHolder={e => e.map((val, index) => e.length - 1 === index ? val : `${val}, `)}
          selectAllOptions
        />
      </div>

      <div>
        <h4>options_3 array of objects, the value is object:</h4>
        <MultipleSelect
          options={options_3}
          selectedValues={values_3}
          onChange={e => setValues_3(e)}
          style={{ borderRadius: '5px', outline: 'none' }}
          selectedOptionStyle={{ color: '#dc143c' }}
          placeHolder='Multiple Select'
          selectedPlaceHolder={e => e.map((val, index) => e.length - 1 === index ? val.value ? val.value : val.id :
            `${val.value ? val.value : val.id}, `)}
          selectAllOptions
        />
      </div>
    </div>
  );
}

export default App;