Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@texada/react-select

JedWatson46MIT1.3.1

A Select control built with and for ReactJS

combobox, form, input, multiselect, react, react-component, select, ui

readme

NPM CDNJS Build Status Coverage Status Supported by Thinkmill

React-Select

A Select control built with and for React. Initially built for use in KeystoneJS.


v2.0.0

A major update to React-select has come! React-Select v2 is a complete rewrite, all new with some major API improvements, a powerful new styles and components API, and support for some long-requested features like option groups.

To install the new version:

yarn add react-select

Check out the v2 documentation and upgrade guide.


Demo & Examples

Live demo: https://v1.react-select.com/

Installation

The easiest way to use react-select is to install it from npm and build it into your app with Webpack.

yarn add react-select@1.x

You can then import react-select and its styles in your application as follows:

import Select from 'react-select';
import 'react-select/dist/react-select.css';

You can also use the standalone UMD build by including dist/react-select.js and dist/react-select.css in your page. If you do this you'll also need to include the dependencies. For example:

<script src="https://unpkg.com/react@15.6.1/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15.6.1/dist/react-dom.js"></script>
<script src="https://unpkg.com/prop-types@15.5.10/prop-types.js"></script>
<script src="https://unpkg.com/classnames@2.2.5/index.js"></script>
<script src="https://unpkg.com/react-input-autosize@2.0.0/dist/react-input-autosize.js"></script>
<script src="https://unpkg.com/react-select@1.2.1/dist/react-select.js"></script>

<link rel="stylesheet" href="https://unpkg.com/react-select@1.2.1/dist/react-select.css">

Usage

React-Select generates a hidden text field containing the selected value, so you can submit it as part of a standard form. You can also listen for changes with the onChange event property.

Options should be provided as an Array of Objects, each with a value and label property for rendering and searching. You can use a disabled property to indicate whether the option is disabled or not.

The value property of each option should be either a string or a number.

When the value is changed, onChange(selectedValueOrValues) will fire. Note that (as of 1.0) you must handle the change and pass the updated value to the Select.

import React from 'react';
import Select from 'react-select';

class App extends React.Component {
  state = {
    selectedOption: '',
  }
  handleChange = (selectedOption) => {
    this.setState({ selectedOption });
    // selectedOption can be null when the `x` (close) button is clicked
    if (selectedOption) {
      console.log(`Selected: ${selectedOption.label}`);
    }
  }
  render() {
    const { selectedOption } = this.state;

    return (
      <Select
        name="form-field-name"
        value={selectedOption}
        onChange={this.handleChange}
        options={[
          { value: 'one', label: 'One' },
          { value: 'two', label: 'Two' },
        ]}
      />
    );
  }
}

You can customise the valueKey and labelKey props to use a different option shape.

Custom classNames

You can provide a custom className prop to the <Select> component, which will be added to the base .Select className for the outer container.

The built-in Options renderer also support custom classNames, just add a className property to objects in the options array.

Multiselect options

You can enable multi-value selection by setting multi={true}. In this mode:

  • Selected options will be removed from the dropdown menu by default. If you want them to remain in the list, set removeSelected={false}
  • The selected values are submitted in multiple <input type="hidden"> fields, use the joinValues prop to submit joined values in a single field instead
  • The values of the selected items are joined using the delimiter prop to create the input value when joinValues is true
  • A simple value, if provided, will be split using the delimiter prop
  • The onChange event provides an array of selected options or a comma-separated string of values (eg "1,2,3") if simpleValue is true
  • By default, only options in the options array can be selected. Use the Creatable Component (which wraps Select) to allow new options to be created if they do not already exist. Hitting comma (','), ENTER or TAB will add a new option. Versions 0.9.x and below provided a boolean attribute on the Select Component (allowCreate) to achieve the same functionality. It is no longer available starting with version 1.0.0.
  • By default, selected options can be cleared. To disable the possibility of clearing a particular option, add clearableValue: false to that option:
    var options = [
    { value: 'one', label: 'One' },
    { value: 'two', label: 'Two', clearableValue: false }
    ];
    Note: the clearable prop of the Select component should also be set to false to prevent allowing clearing all fields at once

Accessibility Note

Selected values aren't focus targets, which means keyboard users can't tab to them, and are restricted to removing them using backspace in order. This isn't ideal and I'm looking at other options for the future; in the meantime if you want to use a custom valueComponent that implements tabIndex and keyboard event handling, see #2098 for an example.

Async options

If you want to load options asynchronously, use the Async export and provide a loadOptions Function.

The function takes two arguments String input, Function callbackand will be called when the input text is changed.

When your async process finishes getting the options, pass them to callback(err, data) in a Object { options: [] }.

The select control will intelligently cache options for input strings that have already been fetched. The cached result set will be filtered as more specific searches are input, so if your async process would only return a smaller set of results for a more specific query, also pass complete: true in the callback object. Caching can be disabled by setting cache to false (Note that complete: true will then have no effect).

Unless you specify the property autoload={false} the control will automatically load the default set of options (i.e. for input: '') when it is mounted.

import { Async } from 'react-select';

const getOptions = (input, callback) => {
  setTimeout(() => {
    callback(null, {
      options: [
        { value: 'one', label: 'One' },
        { value: 'two', label: 'Two' }
      ],
      // CAREFUL! Only set this to true when there are no more options,
      // or more specific queries will not be sent to the server.
      complete: true
    });
  }, 500);
};

<Async
  name="form-field-name"
  loadOptions={getOptions}
/>

Note about filtering async options

The Async component doesn't change the default behaviour for filtering the options based on user input, but if you're already filtering the options server-side you may want to customise or disable this feature (see filtering options below). For example, if you would like to completely disable client side filtering, you can do so with:

filterOptions={(options, filter, currentValues) => {
  // Do no filtering, just return all options
  return options;
}}

Async options with Promises

loadOptions supports Promises, which can be used in very much the same way as callbacks.

Everything that applies to loadOptions with callbacks still applies to the Promises approach (e.g. caching, autoload, ...)

An example using the fetch API and ES6 syntax, with an API that returns an object like:

import { Async } from 'react-select';

/*
 * assuming the API returns something like this:
 *   const json = [
 *      { value: 'one', label: 'One' },
 *      { value: 'two', label: 'Two' }
 *   ]
 */

const getOptions = (input) => {
  return fetch(`/users/${input}.json`)
    .then((response) => {
      return response.json();
    }).then((json) => {
      return { options: json };
    });
}

<Async
  name="form-field-name"
  value="one"
  loadOptions={getOptions}
/>

Async options loaded externally

If you want to load options asynchronously externally from the Select component, you can have the Select component show a loading spinner by passing in the isLoading prop set to true.

import Select from 'react-select';

let isLoadingExternally = true;

<Select
  name="form-field-name"
  isLoading={isLoadingExternally}
  ...
/>

User-created tags

The Creatable component enables users to create new tags within react-select. It decorates a Select and so it supports all of the default properties (eg single/multi mode, filtering, etc) in addition to a couple of custom ones (shown below). The easiest way to use it is like so:

import { Creatable } from 'react-select';

function render (selectProps) {
  return <Creatable {...selectProps} />;
};

Combining Async and Creatable

Use the AsyncCreatable HOC if you want both async and creatable functionality. It ties Async and Creatable components together and supports a union of their properties (listed above). Use it as follows:

import { AsyncCreatable } from 'react-select';

function render (props) {
  // props can be a mix of Async, Creatable, and Select properties
  return (
    <AsyncCreatable {...props} />
  );
}

Filtering options

You can control how options are filtered with the following props:

  • matchPos: "start" or "any": whether to match the text entered at the start or any position in the option value
  • matchProp: "label", "value" or "any": whether to match the value, label or both values of each option when filtering
  • ignoreCase: Boolean: whether to ignore case or match the text exactly when filtering
  • ignoreAccents: Boolean: whether to ignore accents on characters like ø or å

matchProp and matchPos both default to "any". ignoreCase defaults to true. ignoreAccents defaults to true.

Advanced filters

You can also completely replace the method used to filter either a single option, or the entire options array (allowing custom sort mechanisms, etc.)

  • filterOption: function(Object option, String filter) returns Boolean. Will override matchPos, matchProp, ignoreCase and ignoreAccents options.
  • filterOptions: function(Array options, String filter, Array currentValues) returns Array filteredOptions. Will override filterOption, matchPos, matchProp, ignoreCase and ignoreAccents options.

For multi-select inputs, when providing a custom filterOptions method, remember to exclude current values from the returned array of options.

Filtering large lists

The default filterOptions method scans the options array for matches each time the filter text changes. This works well but can get slow as the options array grows to several hundred objects. For larger options lists a custom filter function like react-select-fast-filter-options will produce better results.

Efficiently rendering large lists with windowing

The menuRenderer property can be used to override the default drop-down list of options. This should be done when the list is large (hundreds or thousands of items) for faster rendering. Windowing libraries like react-virtualized can then be used to more efficiently render the drop-down menu like so. The easiest way to do this is with the react-virtualized-select HOC. This component decorates a Select and uses the react-virtualized VirtualScroll component to render options. Demo and documentation for this component are available here.

You can also specify your own custom renderer. The custom menuRenderer property accepts the following named parameters:

Parameter Type Description
focusedOption Object The currently focused option; should be visible in the menu by default.
focusOption Function Callback to focus a new option; receives the option as a parameter.
labelKey String Option labels are accessible with this string key.
optionClassName String The className that gets used for options
optionComponent ReactClass The react component that gets used for rendering an option
optionRenderer Function The function that gets used to render the content of an option
options Array<Object> Ordered array of options to render.
selectValue Function Callback to select a new option; receives the option as a parameter.
valueArray Array<Object> Array of currently selected options.

Updating input values with onInputChange

You can manipulate the input by providing a onInputChange callback that returns a new value. Please note: When you want to use onInputChange only to listen to the input updates, you still have to return the unchanged value!

function cleanInput(inputValue) {
  // Strip all non-number characters from the input
  return inputValue.replace(/[^0-9]/g, "");
}

<Select
  name="form-field-name"
  onInputChange={cleanInput}
/>

Overriding default key-down behaviour with onInputKeyDown

Select listens to keyDown events to select items, navigate drop-down list via arrow keys, etc. You can extend or override this behaviour by providing a onInputKeyDown callback.

function onInputKeyDown(event) {
  switch (event.keyCode) {
    case 9: // TAB
      // Extend default TAB behaviour by doing something here
      break;
    case 13: // ENTER
      // Override default ENTER behaviour by doing stuff here and then preventing default
      event.preventDefault();
      break;
  }
}

<Select
  {...otherProps}
  onInputKeyDown={onInputKeyDown}
/>

Select Props

Property Type Default Description
aria-describedby string undefined HTML ID(s) of element(s) that should be used to describe this input (for assistive tech)
aria-label string undefined Aria label (for assistive tech)
aria-labelledby string undefined HTML ID of an element that should be used as the label (for assistive tech)
arrowRenderer function undefined Renders a custom drop-down arrow to be shown in the right-hand side of the select: arrowRenderer({ onMouseDown, isOpen }). Won't render when set to null
autoBlur boolean false Blurs the input element after a selection has been made. Handy for lowering the keyboard on mobile devices
autofocus boolean undefined deprecated; use the autoFocus prop instead
autoFocus boolean undefined autofocus the component on mount
autoload boolean true whether to auto-load the default async options set
autosize boolean true If enabled, the input will expand as the length of its value increases
backspaceRemoves boolean true whether pressing backspace removes the last item when there is no input value (Also see related prop deleteRemoves)
backspaceToRemoveMessage string 'Press backspace to remove {last label}' prompt shown in input when at least one option in a multiselect is shown, set to '' to clear
className string undefined className for the outer element
clearable boolean true should it be possible to reset value
clearAllText string 'Clear all' title for the "clear" control when multi is true
clearRenderer function undefined Renders a custom clear to be shown in the right-hand side of the select when clearable true: clearRenderer()
clearValueText string 'Clear value' title for the "clear" control
closeOnSelect boolean true whether to close the menu when a value is selected
deleteRemoves boolean true whether pressing delete key removes the last item when there is no input value. (Also see related prop backspaceRemoves)
delimiter string ',' delimiter to use to join multiple values
disabled boolean false whether the Select is disabled or not
escapeClearsValue boolean true whether escape clears the value when the menu is closed
filterOption function undefined method to filter a single option (option, filterString) => boolean
filterOptions boolean or function undefined boolean to enable default filtering or function to filter the options array ([options], filterString, [values]) => [options]
id string undefined html id to set on the input element for accessibility or tests
ignoreAccents boolean true whether to strip accents when filtering
ignoreCase boolean true whether to perform case-insensitive filtering
inputProps object undefined custom attributes for the Input (in the Select-control) e.g: {'data-foo': 'bar'}
inputRenderer function undefined renders a custom input component
instanceId string increment instance ID used internally to set html ids on elements for accessibility, specify for universal rendering
isLoading boolean false whether the Select is loading externally or not (such as options being loaded)
joinValues boolean false join multiple values into a single hidden input using the delimiter
labelKey string 'label' the option property to use for the label
matchPos string 'any' (any, start) match the start or entire string when filtering
matchProp string 'any' (any, label, value) which option property to filter on
menuBuffer number 0 buffer of px between the base of the dropdown and the viewport to shift if menu doesnt fit in viewport
menuContainerStyle object undefined optional style to apply to the menu container
menuRenderer function undefined Renders a custom menu with options; accepts the following named parameters: menuRenderer({ focusedOption, focusOption, options, selectValue, valueArray })
menuStyle object undefined optional style to apply to the menu
multi boolean undefined multi-value input
name string undefined field name, for hidden <input /> tag
noResultsText string 'No results found' placeholder displayed when there are no matching search results or a falsy value to hide it (can also be a react component)
onBlur function undefined onBlur handler: function(event) {}
onBlurResetsInput boolean true Whether to clear input on blur or not. If set to false, it only works if onCloseResetsInput is false as well.
onChange function undefined onChange handler: function(newOption) {}
onClose function undefined handler for when the menu closes: function () {}
onCloseResetsInput boolean true whether to clear input when closing the menu through the arrow
onFocus function undefined onFocus handler: function(event) {}
onInputChange function undefined onInputChange handler/interceptor: function(inputValue: string): string
onInputKeyDown function undefined input keyDown handler; call event.preventDefault() to override default Select behaviour: function(event) {}
onMenuScrollToBottom function undefined called when the menu is scrolled to the bottom
onOpen function undefined handler for when the menu opens: function () {}
onSelectResetsInput boolean true whether the input value should be reset when options are selected. Also input value will be set to empty if 'onSelectResetsInput=true' and Select will get new value that not equal previous value.
onValueClick function undefined onClick handler for value labels: function (value, event) {}
openOnClick boolean true open the options menu when the control is clicked (requires searchable = true)
openOnFocus boolean false open the options menu when the control gets focus
optionClassName string undefined additional class(es) to apply to the <Option /> elements
optionComponent function undefined option component to render in dropdown
optionRenderer function undefined custom function to render the options in the menu
options array undefined array of options
removeSelected boolean true whether the selected option is removed from the dropdown on multi selects
pageSize number 5 number of options to jump when using page up/down keys
placeholder string or node 'Select ...' field placeholder, displayed when there's no value
required boolean false applies HTML5 required attribute when needed
resetValue any null value to set when the control is cleared
rtl boolean false use react-select in right-to-left direction
scrollMenuIntoView boolean true whether the viewport will shift to display the entire menu when engaged
searchable boolean true whether to enable searching feature or not
searchPromptText string or node 'Type to search' label to prompt for search input
simpleValue boolean false pass the value to onChange as a string
style object undefined optional styles to apply to the control
tabIndex string or number undefined tabIndex of the control
tabSelectsValue boolean true whether to select the currently focused value when the [tab] key is pressed
trimFilter boolean true whether to trim whitespace from the filter value
value any undefined initial field value
valueComponent function <Value /> function which returns a custom way to render/manage the value selected <CustomValue />
valueKey string 'value' the option property to use for the value
valueRenderer function undefined function which returns a custom way to render the value selected function (option) {}
wrapperStyle object undefined optional styles to apply to the component wrapper

Async Props

Property Type Default Description
autoload boolean true automatically call the loadOptions prop on-mount
cache object undefined Sets the cache object used for options. Set to false if you would like to disable caching.
loadingPlaceholder string or node 'Loading...' label to prompt for loading search result
loadOptions function undefined function that returns a promise or calls a callback with the options: function(input, [callback])

Creatable properties

Property Type Description
children function Child function responsible for creating the inner Select component. This component can be used to compose HOCs (eg Creatable and Async). Expected signature: (props: Object): PropTypes.element
isOptionUnique function Searches for any matching option within the set of options. This function prevents duplicate options from being created. By default this is a basic, case-sensitive comparison of label and value. Expected signature: ({ option: Object, options: Array, labelKey: string, valueKey: string }): boolean
isValidNewOption function Determines if the current input text represents a valid option. By default any non-empty string will be considered valid. Expected signature: ({ label: string }): boolean
newOptionCreator function Factory to create new option. Expected signature: ({ label: string, labelKey: string, valueKey: string }): Object
onNewOptionClick function new option click handler, it calls when new option has been selected. function(option) {}
shouldKeyDownEventCreateNewOption function Decides if a keyDown event (eg its keyCode) should result in the creation of a new option. ENTER, TAB and comma keys create new options by default. Expected signature: ({ keyCode: number }): boolean
promptTextCreator function Factory for overriding default option creator prompt label. By default it will read 'Create option "{label}"'. Expected signature: (label: String): String
showNewOptionAtTop boolean true: (Default) Show new option at top of list
false: Show new option at bottom of list

Methods

Use the focus() method to give the control focus. All other methods on <Select> elements should be considered private.

// focuses the input element
<instance>.focus();

Contributing

See our CONTRIBUTING.md for information on how to contribute.

Thanks to the projects this was inspired by: Selectize (in terms of behaviour and user experience), React-Autocomplete (as a quality React Combobox implementation), as well as other select controls including Chosen and Select2.

License

MIT Licensed. Copyright (c) Jed Watson 2018.

changelog

React-Select

v1.3.0 / 2018-06-23

v1.2.1 / 2018-01-13

v1.2.0 / 2018-01-08

v1.1.0 / 2017-11-28

  • added; more props are passed to the Option component: focusOption, inputValue, selectValue, removeValue
  • added; the inputValue is passed as the third argument to the optionRenderer
  • fixed; issues opening the menu correctly for multiselect when autosize={false}
  • fixed; removed event.stopPropagation() from Select's clearValue and onClick handlers, thanks Thomas Burke
  • fixed; handleMouseDownOnArrow when openOnClick={false}, thanks elias ghali
  • fixed; conditional scrolling into view of focused option, thanks Michael Lewis

v1.0.1 / 2017-11-24

  • reintroduced source files for scss and less stylesheets into the npm package

v1.0.0 / 2017-11-23

v1.0.0-rc.10 / 2017-09-13

  • changed; openAfterFocus prop has been renamed to openOnClick, and now defaults to true
  • fixed; React.PropTypes deprecation warning, thanks Jeremy Liberman
  • improved; scrolling behaviour when navigating the menu with the keyboard, thanks boatkorachal
  • fixed; error with the Async cache when you type "hasOwnProperty", thanks SuhushinAS

v1.0.0-rc.9 / 2017-09-13

  • fixed; clearable padding style, thanks Minori Miyauchi
  • fixed; removed use of Object.assign, fixes IE compatibility
  • added; new closeOnSelect prop (defaults to true) that controls whether the menu is closed when an option is selected, thanks to Michael Elgar for the original idea
  • changed; by default, the menu for multi-selects now closes when an option is selected
  • changed; Async component no longer always clears options when one is selected (although the menu is now closed by default). Use closeOnSelect={false} onSelectResetsInput={false} to leave the menu open.
  • fixed; Async component always called onChange even when it wasn't provided
  • fixed; input lag for the Async component when results are returned from cache
  • fixed; required was not being updated without an onChange handler
  • fixed; peer dependencies for prop-types, thanks Michaël De Boey
  • fixed; internal optimisations, thanks Kieran Boyle
  • added; Value component is now exported, thanks Prof Gra
  • fixed; callback fired after Async component unmounts, thanks Andrew Russell
  • fixed; wrapping on Firefox in SCSS files, thanks Michael Williamson

v1.0.0-rc.8 / 2017-09-12

v1.0.0-rc.7 / 2017-09-11

  • fixed; issue with lib build preventing use in ES2015 environments

v1.0.0-rc.6 / 2017-09-10

  • fixed; changing required prop from true to false now works as expected, thanks George Karagkiaouris
  • added; new prop onSelectResetsInput controls whether the input value is cleared when options are selected, thanks David Roeca and Alexander Nosov
  • fixed; tabindex parent bug fix for Edge, thanks George Payne
  • fixed; update selectize link in README.md, thanks kerumen
  • added; standard issue template, thanks agirton
  • added; new build process using rollup and webpack. Removed grunt. thanks gwyneplaine
  • fixed; updated contributor docs with the correct node version reference gwyneplaine
  • fixed; missing method binds in Option, thanks agirton
  • fixed; converted components to use es6 classes, thanks jochenberger
  • fixed; console.log example in usage docs, thanks rohmanhm
  • fixed; hide create option after closing menu, thanks andreme
  • fixed; remove circular reference, thanks agirton
  • fixed; readme typo, thanks ieldanr
  • fixed; add missing function binds in Option component, thanks agirton and blacktemplar
  • fixed; re-added fix to #1580, thanks agirton
  • fixed; avoid mutating user inputs when ignoring case/accents, thanks not-an-aardvark
  • fixed; issues synchronising options props in Async, thanks cbergmiller
  • fixed; backspace handling for non-multi select controls, thanks Jeremy Liberman

v1.0.0-rc.5 / 2017-05-25

  • fixed; Allow falsey values to be clearable, thanks Simon Gaestel
  • fixed; issue where Firefox would crash due to incorrect use of aria-owns attribute, thanks Max Hubenthal
  • fixed; regression where options not using the value key couldn't be focused, thanks Benjamin Piouffle

v1.0.0-rc.4 / 2017-05-14

  • fixed; no more warning when using React 15.5, thanks Adam Girton
  • fixed; issue comparing objects in getFocusableOptionIndex, thanks rndm2
  • fixed; missing .focus() method in Creatable, thanks Anton Alexandrenok
  • added; support for aria-describedby attribute, thanks Eric Lee
  • added; .is-clearable className when clearable is true, thanks Dan Diaz

v1.0.0-rc.3 / 2017-02-01

  • added; arrowRenderer prop, thanks Brian Vaughn
  • added; child-function support to Async and Creatable components so that they can compose each other (or future HOCs), thanks Brian Vaughn
  • added; asyncCreatable HOC that combines Async and Creatable so they can be used together, thanks Brian Vaughn
  • added; undocumented arguments for menuRenderer, thanks Julian Krispel-Samsel
  • fixed; Do not focus and open menu when disabled, thanks nhducit
  • fixed; Scrolling with arrow-keys is not working correctly, thanks Damian Pieczynski
  • added; "select all text" functionality Shift+Home|Del, thanks Damian Pieczynski
  • added; support for boolean values, thanks Aaron Hardy
  • fixed; Remove duplicated promptTextCreator field from readme, thanks Jih-Chi Lee
  • fixed; Adding back ref that was removed in rc2, thanks Martin Jujou
  • fixed; Creatable component doesn't allow input key down handling, thanks Ivan Leonenko
  • added; Allow react nodes to be passed as loadingPlaceholder, thanks Daniel Heath
  • fixed; IE8 compatibility issues, thanks Kirill Mesnyankin
  • improved; Allow users to specify noResultsText, thanks Daniel Heath
  • added; Only remove options if a loading placeholder is available, thanks Daniel Heath
  • fixed; firefox display items in two rows due to reflow, thanks Daniel Heath
  • fixed; Creatable readme typo, thanks Ben
  • fixed; explain way to implement allowCreate functionality with Creatable to readme, thanks mayerwin
  • added; delete key removes an item when there is no input, thanks forum-is
  • added; onNewOptionClick handler for Creatable, thanks Lee Siong Chan
  • fixed; onInputChange consistent for Creatable, thanks Lee Siong Chan
  • fixed; menuRenderer is treated consistently between Creatable and Select, thanks Brian Vaughn
  • fixed; asyncCreatable options parsing will not parse undefined values into props, thanks Romain Dardour
  • added; pass inputProps to inputRenderer, thanks Alec Winograd
  • fixed; no exception when clearing an Async field that is not set to multi, thanks Patrik Stutz
  • added; allow rendering a custom clear component, thanks Conor Hastings
  • fixed; document ignoreAccents, thanks Domenico Matteo
  • fixed; arrowing up or down in Select with 0 options does not throw type error, thanks Alex Howard
  • fixed; Creatable handles null children prop, thanks Jack Coulter
  • added; provide isOpen to arrowRenderer, thanks Kuan
  • fixed; re-added the focus() method on Select.Async, thanks, Maarten Claes
  • fixed; focus the next available option after a selection, not the top option, thanks Nicolas Raynaud

Note there has also been a breaking change to the props for the Async component: both minimumInput and searchingText have been removed. See #1226 for more details. Apologies for doing this in an RC release, but we had to trade off between resolving some important bugs and breaking the API, and figured it was better to do this before declaring 1.0.0 stable.

v1.0.0-rc.1 / 2016-09-04

  • fixed; reset value to [] when multi=true, thanks Michael Williamson
  • added; pass index to renderLabel method, thanks nhducit
  • fixed; uncontrolled to controlled component warning in React 15.3
  • fixed; props cleanup, thanks Forbes Lindesay
  • fixed; issue where a value of the number 0 would be assumed to be no value, thanks Hanwen Cheng
  • fixed; internal refs converted to callbacks instead of strings, thanks Johnny Nguyen
  • added; optional instanceId prop for server-side rendering, thanks Jevin Anderson
  • added; onCloseResetsInput prop, thanks Frankie
  • added; Creatable component, replaces pre-1.0 allowCreate prop, thanks Brian Vaughn

v1.0.0-beta14 / 2016-07-17

  • fixed; react-input-autosize has been udpated to 1.1.0, which includes fixes for the new warnings that React 15.2 logs
  • fixed; "Unknown prop inputClassName on
    tag" warning, thanks Max Stoiber
  • fixed; Removed unnecessary onUnfocus, thanks Johnny Nguyen
  • added; Support for react components in searchPromptText, thanks Matt
  • fixed; focus bug on iOS, thanks Tony deCatanzaro
  • fixed; Async bugs with Promises, thanks Vladimir and Ian Firkin
  • fixed; searchingText bug, thanks Tony deCatanzaro
  • improved; More antive-like input behaviour, thanks Johnny Nguyen
  • fixed; Added missing unit (px) to minWidth attribute, thanks Ian Witherow
  • added; Support for assistive technologies, thanks Dave Brotherstone
  • fixed; React error if onChange callback causes a root component to unmount, thanks Nathan Norton
  • fixed; Open menu is now closed if disabled becomes true, thanks Jason Moon
  • fixed; Prevent getFocusableOptionIndex from returning a disabled option, thanks Brian Powers
  • added; Home, End, Page Up/Down support, thanks Jason Kadrmas
  • fixed; Don't render backspaceToRemoveMessage if backspaceRemoves is set to false, thanks Ryan Zec
  • fixed; Issue with an outline appearing on the auto sized input, thanks Ryan Zec
  • fixed; Events don't propagate when esc is pressed, thanks Yoshihide Jimbo
  • fixed; Update required prop based on nextProps on update, thanks Matt Shwery
  • fixed; On focus check whether input ref is a real input or an input component, thanks Peter Brant and Greg Poole

Also a big thanks to Brian Vaughn for his help triaging issues for this release!

v1.0.0-beta13 / 2016-05-30

  • added; inputRenderer prop, allows you to override the input component, thanks Sean Burke
  • added; openOnFocus prop, causes the menu to always open when the select control is focused, thanks HuysentruytRuben
  • added; react-virtualised-select HOC example, thanks Brian Vaughn
  • added; tabSelectsValue prop can be set to false to prevent selection of focused option when tab is pressed, thanks Byron Anderson
  • added; ability to override resetValue when clearing the control, thanks Alexander Luberg
  • added; input can be updated with onInputChange, thanks Brett DeWoody
  • added; Styles for .is-selected class, thanks Danny Herran
  • fixed; noResultsText prop type is now stringOrNode for Async component, thanks Michael Groeneman
  • fixed; onInputChange is wrapped by Async component, thanks Eric O'Connell
  • fixed; scrollMenuIntoView behaviour in IE10, thanks Ivan Jager
  • fixed; isEqualNode replaced with strict equality check, thanks Alexandre Balhier
  • fixed; issue with value object not being passed to handleRequired, thanks Andrew Hite
  • fixed; the menu-outer container is no longer rendered when it does not contain anything, thanks Kuan
  • improved; better support for IE8 in styles, thanks Rockallite Wulf

v1.0.0-beta12 / 2016-04-02

  • added; menuRenderer method and example for effeciently rendering thousands of options, thanks Brian Vaughn
  • added; optionClassName prop, thanks Max Tyler

v1.0.0-beta11 / 2016-03-09

  • updated dependencies to allow use with React 15.x
  • changed; multiple selected values are now submitted using multiple inputs, thanks Trinh Hoang Nhu
  • added; joinValues prop to revert the above change and submit multiple values in a single field with the delimiter

v1.0.0-beta10 / 2016-02-23

  • fixed build issues with v1.0.0-beta9

v1.0.0-beta9 / 2016-02-12

  • added; onBlurResetsInput prop, thanks Sly Bridges
  • changed; Enter selects and retains focus, Tab selects and shifts focus, thanks RDX
  • fixed; Hide noResultsText when value is falsy, thanks Fernando Alex Helwanger
  • added; required prop, adds HTML5 required attribute, thanks Domenico Matteo
  • fixed; Touch drag behaviour, thanks Pavel Tarnopolsky
  • added; onOpen and onClose event props, thanks Jacob Page
  • fixed; Pressing Enter on open Select should stop propagation, thanks Jeremy Liberman
  • fixed; Missing handleMouseDownOnMenu, thanks Jeremy Liberman
  • added; Ensures the selected option is immediately visible when the menu is open, thanks Martin Jujou
  • added; autoBlur prop, blurs the input when a value is selected, thanks Pavel Tarnopolsky
  • fixed; Several isFocused checks weren't working properly

v1.0.0-beta8 / 2015-12-20

  • fixed; input focus bug when toggling disabled prop, thanks Davide Curletti
  • fixed; focus() is now exposed on the Async component, thanks AugustinLF

v1.0.0-beta7 / 2015-12-15

  • You can now use React elements for placeholders and the text props, thanks kromit and Alyssa Biasi
  • Fixed a problem where the border doesn't show when the element is inside a table, thanks Rodrigo Boratto
  • New prop scrollMenuIntoView scrolls the viewport to display the menu, thanks Alexander Zaharakis
  • New LESS / SCSS variable select-option-bg lets you control the menu option background color, thanks Evan Goldenberg
  • Fixed an error in the blur handler on IE when the menu is not visible, thanks Gaston Sanchez
  • Added support for a clearableValue option property in multi mode, thanks Sly Bridges

v1.0.0-beta6 / 2015-11-29

  • Test suite complete and passing, with a couple of minor fixes thanks to @bruderstein

v1.0.0-beta5 / 2015-11-08

  • Fixes issues relating to serializing simple values into the hidden field

v1.0.0-beta4 / 2015-11-08

We're potentially going to ship some theme stylesheets in the future, shout out on GitHub if this interests you.

v1.0.0-beta3 / 2015-11-08

  • The selected value populated in the hidden field has been fixed (was "[object Object]" before)
  • Added new autofocus prop
  • Fixed duplicate key error for options and values with duplicate value properties
  • SCSS variables now have !default so you can override them

v1.0.0-beta2 / 2015-11-06

Changed since beta 1:

  • Async options cache works again
  • New style props for custom styling the component without modifying css classes: style wrapperStyle menuStyle menuContainerStyle
  • The menu opens and closes correctly when searchable={false}, there is still some work to do on this use-case

v1.0.0-beta1 / 2015-11-06

This is a complete rewrite. Major changes include:

  • Everything is simpler (I'm nearly done and the source code is only 60% of the size of the last version)
  • No more timeouts or weird handlers, the restructuring has let me make everything more straight-forward
  • The options array is no longer preprocessed into state, just retrieved from props
  • The values array is now initialised in the Options array during render, and not stored in state, which along with the change to options makes the component more reliable and fixes issues with props not updating correctly
  • The component no longer stores its own value in state (ever) - it needs to be passed as a prop and handled with onChange.
  • Complex values are now enabled by default (so you're passed the option object, not its value); you can enable the legacy mode with a prop
  • The Value and Option components have been cleaned up as well for consistency
  • The hidden <input> field is now optional and the component is better suited to use in a rich React.js app than it was
  • You can disable options filtering to do the filtering externally with onInputChange
  • Accents on characters can now be ignored
  • The asyncOptions prop has been replaced by a new wrapper component: Select.Async

Note that "Tag mode" (creating options on the fly) isn't reimplemented yet.

A full guide to the breaking changes and new features will be written up soon. In the meantime please see the new examples.

v0.9.1 / 2015-11-01

  • added; new Contributors example w/ async options loading and custom value / label keys
  • fixed; several issues with custom valueKey and labelKey props
  • fixed; autoload now loads options with no search input

v0.9.0 / 2015-10-29

  • added; SCSS stylesheets!
  • improved; Options rendering should be more performant
  • breaking change; Custom Option components now need to pass their option prop to event handlers; see this commit for an example of the required change.

v0.8.4 / 2015-10-27

  • fixed; LESS math operations now work with --strict-math=on, thanks Vincent Fretin

v0.8.3 / 2015-10-27

  • fixed; IE issue where clicking the scrollbar would close the menu, thanks Pete Nykänen

v0.8.2 / 2015-10-22

v0.8.1 / 2015-10-20

  • fixed; loadAsyncOptions raises TypeError in setup, see #439 for details, thanks Pancham Mehrunkar

v0.8.0 / 2015-10-19

This release contains significant DOM structure and CSS improvements by @jossmac, including:

  • no more position: absolute for inner controls
  • display: table is used for layout, which works in IE8 and above, and all other modern browsers
  • less "magic numbers" used for layout, should fix various browser-specific alignment issues
  • clear "x" control now animates in
  • clearer .Select--multi className replaces .Select.is-multi
  • new height & theme variables
  • "dropdown" indicator chevron is no longer displayed for multi-select controls

There are no functional changes, but if you've forked the LESS / CSS to create your own theme you'll want to pay close attention to PR #527 when upgrading to this version.

v0.7.0 / 2015-10-10

React Select is updated for React 0.14. If you're still using React 0.13, please continue to use `react-select@0.6.x`. There are no functional differences between v0.7.0 and v0.6.12.

Additionally, our tests now require Node.js 4.x. If you are developing react-select, please make sure you are running the latest version of node.

Thanks to @bruderstein, @dmatteo and @hull for their help getting these updates shipped!

v0.6.12 / 2015-10-02

  • added; labelKey and valueKey props, so you can now use different keys in option objects for the label and value
  • fixed; additional isMounted() checks in timeouts
  • fixed; componentDidUpdate timeout is reset correctly, see #208 and #434, thanks Petr Gladkikh
  • fixed; mousedown event on scrollbar in menu no longer hides it, thanks Yishai Burt

v0.6.11 / 2015-09-28

  • added; isLoading prop, allows indication of async options loading in situations where more control is required, thanks Jon Gautsch

v0.6.10 / 2015-09-24

  • fixed; a build issue with the previous release that prevented the stylesheet being generated / included
  • fixed; a LESS syntax issue, thanks Bob Cardenas

v0.6.9 / 2015-09-19

  • added; style key for package.json, thanks Stephen Wan
  • added; onInputChange handler that returns the current input value, thanks Tom Leslie
  • fixed; simplifying handleKey function & preventDefault behaviour, thanks davidpene
  • fixed; Display spinner while auto-loading initial data, thanks Ben Jenkinson
  • fixed; better support for touch events, thanks Montlouis-Calixte Stéphane
  • fixed; prevent value splitting on non-multi-value select, thanks Alan R. Soares

v0.6.8 / 2015-09-16

  • fixed; broader range of allowed prereleases for React 0.14, including rc1
  • fixed; preventing backspace from navigating back in the browser history, thanks davidpene

v0.6.7 / 2015-08-28

  • fixed; missing styles for .Select-search-prompt and .Select-searching issues, thanks Jaak Erisalu and davidpene

v0.6.6 / 2015-08-26

  • fixed; issue in Chrome where clicking the scrollbar would close the menu, thanks Vladimir Matsola

v0.6.5 / 2015-08-24

  • fixed; completely ignores clicks on disabled items, unless the target of the click is a link, thanks Ben Stahl

v0.6.4 / 2015-08-24

This release includes a huge improvement to the examples / website thanks to @jossmac. Also:

  • added; support for React 0.14 beta3
  • fixed; disabled options after searching, thanks @bruderstein
  • added; support for "Searching..." text (w/ prop) while loading async results, thanks @bruderstein and @johnomalley
  • added; className, style and title keys are now supported in option properties, thanks @bruderstein

v0.6.3 / 2015-08-18

Otherwise known as "the real 0.6.2" this includes the updated build for the last version; sorry about that!

v0.6.2 / 2015-08-13

  • changed; if the searchable prop is false, the menu is opened or closed on click, more like a standard Select input. thanks MaaikeB

v0.6.1 / 2015-08-09

  • added; Support for options with numeric values, thanks Dave Brotherstone
  • changed; Disabled options now appear in the search results , thanks Dave Brotherstone
  • fixed; asyncOptions are reloaded on componentWillReceiveProps when the value has changed, thanks Francis Cote
  • added; cacheAsyncResults prop (default true) now controls whether the internal cache is used for asyncOptions

v0.6.0 / 2015-08-05

  • improved; option, value and single value have been split out into their own components, and can be customised with props. see #328 for more details.
  • improved; Near-complete test coverage thanks to the awesome work of Dave Brotherstone
  • improved; Support all alpha/beta/rc's of React 0.14.0, thanks Sébastien Lorber
  • fixed; Close multi-select menu when tabbing away, thanks Ben Alpert
  • fixed; Bug where Select shows the value instead of the label (reapplying fix)
  • fixed; valueRenderer now works when multi={false}, thanks Chris Portela
  • added; New property backspaceRemoves (default true), allows the default behaviour of removing values with backspace when multi={true}, thanks Leo Lehikoinen

v0.5.6 / 2015-07-27

  • fixed; Allow entering of commas when allowCreate is on but multi is off, thanks Angelo DiNardi
  • fixed; Times (clear) character is now rendered from string unicode character for consistent output, thanks Nibbles
  • fixed; allowCreate bug, thanks goodzsq
  • fixed; changes to props.placeholder weren't being reflected correctly, thanks alesn
  • fixed; error when escape is pressedn where clearValue was not passed the event, thanks Mikhail Kotelnikov
  • added; More tests, thanks Dave Brotherstone

v0.5.5 / 2015-07-12

  • fixed; replaced usage of component.getDOMNode() with React.findDOMNode(component) for compatibility with React 0.14

v0.5.4 / 2015-07-06

  • fixed; regression in 0.5.3 that broke componentWillMount, sorry everyone!
  • added; addLabelText prop for customising the "add {label}?" text when in tags mode, thanks Fenn

v0.5.3 / 2015-07-05

v0.5.2 / 2015-06-28

  • fixed; bug where Select shows the value instead of the label, thanks Stephen Demjanenko
  • added; 'is-selected' classname is added to the selected option, thanks Alexey Volodkin
  • fixed; async options are now loaded with the initial value, thanks Pokai Chang
  • fixed; react-input-autosize now correctly escapes ampersands (&), not actually a fix in react-select but worth noting here because it would have been causing a problem in react-select as well.

v0.5.1 / 2015-06-21

  • added; custom option and value rendering capability, thanks Brian Reavis
  • fixed; collapsing issue when single-select or empty multi-select fields are disabled
  • fixed; issue where an empty value would be left after clearing all values in a multi-select field

v0.5.0 / 2015-06-20

  • fixed; esc key incorrectly created empty options, thanks rgrzelak
  • adeed; New feature to allow option creation ("tags mode"), enable with allowCreate prop, thanks Florent Vilmart and Brian Reavis
  • fixed; IE8 compatibility fallback for addEventListener/removeEventListener, which don't exist in IE8, thanks Stefan Billiet
  • fixed; Undefined values when using asyncOptions, thanks bannaN
  • fixed; Prevent add the last focused value when the drop down menu is closed / Pushing enter without dropdown open adds a value, thanks Giuseppe
  • fixed; Callback context is undefined, thanks Giuseppe
  • fixed; Issue with event being swallowed on Enter keydown, thanks Kevin Burke
  • added; Support for case-insensitive filtering when matchPos="start", thanks wesrage
  • added; Support for customizable background color, thanks John Morales
  • fixed; Updated ESLint and cleared up warnings, thanks Alexander Shemetovsky
  • fixed; Close dropdown when clicking on select, thanks Nik Butenko
  • added; Tests, and mocha test framework, thanks Craig Dallimore
  • fixed; You can now start the example server and watch for changes with npm start

v0.4.9 / 2015-05-11

  • fixed; focus was being grabbed by the select when autoload and asyncOptions were set
  • added; focus method on the component
  • added; support for disabled options, thanks Pasha Palangpour
  • improved; more closures, less binds, for better performance, thanks Daniel Cousens

v0.4.8 / 2015-05-02

  • fixed; restored dist/default.css
  • fixed; standalone example works again
  • fixed; clarified dependency documentation and added dependencies for Bower
  • fixed; Scoping issues in _bindCloseMenuIfClickedOutside, thanks bannaN
  • fixed; Doesnt try to set focus afterupdate if component is disabled, thanks bannaN

v0.4.7 / 2015-04-21

v0.4.6 / 2015-04-06

  • updated; dependencies, build process and input-autosize component

v0.4.5 / 2015-03-28

  • fixed; issue with long options overlapping arrow and clear icons, thanks Rohit Kalkur

v0.4.4 / 2015-03-26

  • fixed; error handling click events when the menu is closed, thanks Ilya Petrov
  • fixed; issue where options will not be filtered in certain conditions, thanks G. Kay Lee

v0.4.3 / 2015-03-25

  • added tests and updated dependencies

v0.4.2 / 2015-03-23

  • added; ESLint and contributing guide
  • fixed; incorrect classnames variable assignment in window scope
  • fixed; all ESLint errors and warnings (except invalid JSX undefined/unused vars due to ESLint bug)
  • fixed; first option is now focused correctly, thanks Eivind Siqveland Larsen

v0.4.1 / 2015-03-20

  • fixed; IE11 issue: clicking on scrollbar within menu no longer closes menu, thanks Rohit Kalkur

v0.4.0 / 2015-03-12

  • updated; compatible with React 0.13

v0.3.5 / 2015-03-09

  • improved; less/no repaint on scroll for performance wins, thanks jsmunich
  • added; onBlur and onFocus event handlers, thanks Jonas Budelmann
  • added; support for inputProps prop, passed to the <input> component, thanks Yann Plantevin
  • changed; now using react-component-gulp-tasks for build
  • fixed; issue w/ remote callbacks overriding cached options, thanks Corey McMahon
  • fixed; if not this.props.multi, menu doesn't need handleMouseDown, thanks wenbing

v0.3.4 / 2015-02-23

  • fixed; issues with the underscore/lodash dependency change, thanks Aaron Powell

v0.3.3 / 2015-02-22

v0.3.2 / 2015-01-30

  • fixed; issue adding undefined values to multiselect, thanks Tejas Dinkar

v0.3.1 / 2015-01-20

  • fixed; missing var statement

v0.3.0 / 2015-01-20

  • added; node compatible build now available in /lib

v0.2.14 / 2015-01-07

  • added; searchPromptText property that is displayed when asyncOptions is set and there are (a) no options loaded, and (b) no input entered to search on, thanks Anton Fedchenko
  • added; clearable property (defaults to true) to control whether the "clear" control is available, thanks Anton Fedchenko

v0.2.13 / 2015-01-05

  • fixed; height issues in Safari, thanks Joss Mackison
  • added; Option to specify "Clear value" label as prop for i18n

v0.2.12 / 2015-01-04

  • fixed; UI now responds to touch events, and works on mobile devices! thanks Fraser Xu

v0.2.11 / 2015-01-04

  • fixed; Options in the dropdown now scroll into view when they are focused, thanks Adam
  • improved; Example dist is now excluded from the npm package

v0.2.10 / 2015-01-01

  • fixed; More specific mixin name to avoid conflicts (css)
  • fixed; Example CSS now correctly rebuilds on changes in development
  • fixed; Values are now expanded correctly when options change (see #28)
  • added; Option to specify "No results found" label as prop for i18n, thanks Julen Ruiz Aizpuru

v0.2.9 / 2014-12-09

  • added; filterOption and filterOptions props for more control over filtering

v0.2.8 / 2014-12-08

  • added; matchPos option to control whether to match the start or any position in the string when filtering options (default: any)
  • added; matchProp option to control whether to match the value, label or any property of each option when filtering (default: any)

v0.2.7 / 2014-12-01

  • fixed; screen-readers will now read "clear value" instead of "times" for the clear button
  • fixed; non-left-click mousedown events aren't blocked by the control

v0.2.6 / 2014-11-30

  • improved; better comparison of changes to [options] in willReceiveProps
  • fixed; now focuses the first option correctly when in multiselect mode
  • fixed; fixed focused option behaviour on value change
  • fixed; when filtering, there is always a focused option (#19)
  • changed; using ^ in package.json to compare dependencies

v0.2.5 / 2014-11-20

  • fixed; compatibility with case-sensitive file systems

v0.2.4 / 2014-11-20

  • fixed; package.json pointed at the right file

v0.2.3 / 2014-11-17

  • fixed; Updating state correctly when props change
  • improved; Build tasks and docs
  • added; Working standalone build
  • added; Minified dist version
  • added; Publised to Bower

v0.2.2 / 2014-11-15

  • fixed; backspace event being incorrectly cancelled

v0.2.1 / 2014-11-15

  • fixed; issue where backspace incorrectly clears the value (#14)

v0.2.0 / 2014-11-15

  • changed; Major rewrite to improve focus handling and internal state management
  • added; Support for multi prop, enable multiselect mode

v0.1.1 / 2014-11-03

  • added; Support for onChange event
  • added; propTypes are defined by the Select component now
  • added; className property, sets the className on the outer div element
  • fixed; Removed deprecated React.DOM.x calls

v0.1.0 / 2014-11-01

  • updated; React to 0.12.0

v0.0.6 / 2014-10-14

  • fixed; Error keeping value when using Async Options