What is react-select?
The react-select npm package is a flexible and customizable select input control for React applications. It provides a powerful set of features that allow developers to create simple dropdowns, multi-selects, async data loading, and more, with a focus on accessibility and customizability.
What are react-select's main functionalities?
Basic Single Select
This feature allows you to create a basic single selection dropdown where a user can select one option from a predefined list.
{"import Select from 'react-select';\n\nconst options = [\n { value: 'chocolate', label: 'Chocolate' },\n { value: 'strawberry', label: 'Strawberry' },\n { value: 'vanilla', label: 'Vanilla' }\n];\n\nconst MyComponent = () => (\n <Select options={options} />\n);"}
Multi-Select
This feature enables users to select multiple options from the dropdown. It is useful for fields that require more than one selection.
{"import Select from 'react-select';\n\nconst options = [\n { value: 'chocolate', label: 'Chocolate' },\n { value: 'strawberry', label: 'Strawberry' },\n { value: 'vanilla', label: 'Vanilla' }\n];\n\nconst MyComponent = () => (\n <Select isMulti options={options} />\n);"}
Asynchronous Loading
This feature allows for loading options asynchronously, which is useful when the options are not available at initial render time or need to be fetched based on user input.
{"import Select from 'react-select';\nimport AsyncSelect from 'react-select/async';\n\nconst loadOptions = (inputValue, callback) => {\n setTimeout(() => {\n callback(filterOptions(inputValue));\n }, 1000);\n};\n\nconst MyComponent = () => (\n <AsyncSelect loadOptions={loadOptions} />\n);"}
Creatable Select
This feature allows users to create a new option on the fly if the option they are looking for is not available in the list.
{"import CreatableSelect from 'react-select/creatable';\n\nconst options = [\n { value: 'chocolate', label: 'Chocolate' },\n { value: 'strawberry', label: 'Strawberry' },\n { value: 'vanilla', label: 'Vanilla' }\n];\n\nconst MyComponent = () => (\n <CreatableSelect isMulti options={options} />\n);"}
Other packages similar to react-select
downshift
Downshift is a set of primitives to build simple, flexible, WAI-ARIA compliant enhanced input React components. Its major focus is on flexibility and providing the building blocks for creating custom dropdown components. It is more low-level than react-select and requires more boilerplate to achieve similar functionality.
react-autosuggest
React-autosuggest is a WAI-ARIA compliant React autosuggest component that provides a simple yet customizable input field with suggestions. While it is similar to react-select in providing suggestions, it does not offer as many features out of the box, such as multi-select or async options.
antd
Ant Design (antd) is a design system with a set of high-quality React components, one of which is a Select component. It offers a comprehensive suite of features similar to react-select but is part of a larger framework, which might be more than needed if only a select component is required.
React-Select
A Select control built with and for React. Initially built for use in KeystoneJS.
V2 Alpha
This is an experimental branch for the new v2 react-select component. Explanation and Docs to be written.
License
MIT Licensed. Copyright (c) Jed Watson 2018.