diff --git a/README.md b/README.md index 860fc0a75c..93b17c6ea5 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,29 @@ var isLoadingExternally = true; /> ``` +### 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: + +```js +import { Creatable } from 'react-select'; + +function render (selectProps) { + return ; +}; +``` + +##### Creatable properties + +Property | Type | Description +:---|:---|:--- +`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: `(newOption: 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` | +`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 dfeault. Expected signature: `(keyCode: number): boolean` | + ### Filtering options You can control how options are filtered with the following properties: @@ -263,7 +286,6 @@ function cleanInput(inputValue) { Property | Type | Default | Description :-----------------------|:--------------|:--------------|:-------------------------------- addLabelText | string | 'Add "{label}"?' | text to display when `allowCreate` is true - allowCreate | bool | false | allow new options to be created in multi mode (displays an "Add \