1.0.12 • Published 3 months ago

sbes-react-multi-select-component v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

react-multi-select-component

Simple and lightweight multiple selection dropdown component with checkboxes, search and select-all

Storybook GitHub Actions Status NPM gzip

✨ Features

  • 🕶 Zero Dependency
  • 🍃 Lightweight (<5KB)
  • 💅 Themeable
  • ✌ Written w/ TypeScript

🔧 Installation

npm i react-multi-select-component    # npm
yarn add react-multi-select-component # yarn

📦 Example

Example

import React, { useState } from "react";
import { MultiSelect } from "react-multi-select-component";

const options = [
  { label: "Grapes 🍇", value: "grapes" },
  { label: "Mango 🥭", value: "mango" },
  { label: "Strawberry 🍓", value: "strawberry", disabled: true },
];

const Example = () => {
  const [selected, setSelected] = useState([]);

  return (
    <div>
      <h1>Select Fruits</h1>
      <pre>{JSON.stringify(selected)}</pre>
      <MultiSelect
        options={options}
        value={selected}
        onChange={setSelected}
        labelledBy="Select"
      />
    </div>
  );
};

export default Example;

More examples can be found here ↗

👀 Props

PropDescriptionTypeDefault
labelledByvalue for aria-labelledbystring
optionsoptions for dropdown[{label, value, disabled}]
valuepre-selected rows[{label, value}][]
hasSelectAlltoggle 'Select All' optionbooleantrue
isLoadingshow spinner on selectbooleanfalse
shouldToggleOnHovertoggle dropdown on hover optionbooleanfalse
overrideStringslocalization ↗object
onChangeonChange callbackfunction
disableddisable dropdownbooleanfalse
disableSearchhide search textboxbooleanfalse
filterOptionscustom filter options (async supported) ↗functionFuzzy Search
classNameclass name for parent componentstringmulti-select
valueRenderercustom dropdown header ↗function
ItemRenderercustom dropdown option ↗function
ClearIconCustom Clear Icon for SearchReactNode
ArrowRendererCustom Arrow Icon for DropdownReactNode
debounceDurationdebounce duration for Searchnumber300
ClearSelectedIconCustom Clear Icon for Selected Items (Hint: Pass null to prevent it from rendering completely)ReactNode
isCreatableAllows user to create unavailable option(s) example ↗booleanfalse
onCreateOptionallows to override newly created option example ↗function
closeOnChangedValueautomatically closes dropdown when its value is changedbooleanfalse

📝 Changelog

For every release changelog/migration-guide will be available in releases

🤠 Credits

📜 License

MIT © harshzalavadiya

1.0.11

3 months ago

1.0.12

3 months ago

1.0.10

4 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago