You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 23, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+21-13Lines changed: 21 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ If you want to try the component yourself instead of watching a gif, head over t
11
11
12
12
## Installation
13
13
```shell
14
-
npm i --save material-ui-chip-input
14
+
npm i --save material-ui-chip-input@next
15
15
```
16
16
17
17
## Usage
@@ -38,43 +38,51 @@ import ChipInput from 'material-ui-chip-input'
38
38
| Name | Type | Default | Description |
39
39
| --- | --- | --- | --- |
40
40
| allowDuplicates |`bool`|`false`| Allows duplicate chips if set to true. |
41
-
|chipContainerStyle|`object`||Override the inline-styles of the chip container element. |
42
-
|chipRenderer|`function`||A function of the type `({ value, text, chip, isFocused, isDisabled, handleClick, handleRequestDelete, defaultStyle }, key) => node` that returns a chip based on the given properties. This can be used to customize chip styles. Each item in the `dataSource` array will be passed to `chipRenderer` as arguments `chip`, `value` and `text`. If `dataSource` is an array of objects and `dataSourceConfig` is present, then `value` and `text` will instead correspond to the object values defined in `dataSourceConfig`. If `dataSourceConfig` is not set and `dataSource` is an array of objects, then a custom `chipRenderer` must be set. `chip` is always the raw value from `dataSource`, either an object or a string.|
41
+
|chipRenderer|`function`||A function of the type `({ value, text, chip, isFocused, isDisabled, handleClick, handleRequestDelete, className }, key) => node` that returns a chip based on the given properties. This can be used to customize chip styles. Each item in the `dataSource` array will be passed to `chipRenderer` as arguments `chip`, `value` and `text`. If `dataSource` is an array of objects and `dataSourceConfig` is present, then `value` and `text` will instead correspond to the object values defined in `dataSourceConfig`. If `dataSourceConfig` is not set and `dataSource` is an array of objects, then a custom `chipRenderer` must be set. `chip` is always the raw value from `dataSource`, either an object or a string.|
42
+
|classes|`object`||Extends the styles applied to this component. |
43
43
| clearOnBlur |`bool`|`true`| If true, clears the input value after the component loses focus. |
44
44
| dataSource |`array`|| Data source for auto complete. This should be an array of strings or objects.|
45
45
| dataSourceConfig |`object`|| Config for objects list dataSource, e.g. `{ text: 'text', value: 'value' }`. If not specified, the `dataSource` must be a flat array of strings or a custom `chipRenderer` must be set to handle the objects. |
46
46
| defaultValue |`string[]`|| The chips to display by default (for uncontrolled mode). |
47
47
| disabled |`bool`|`false`| Disables the chip input if set to true. |
48
-
| errorText |`node`|| The error text to display. |
49
-
| floatingLabelText |`node`|| The content of the floating label. |
48
+
| helperText |`node`|| The helper text to display. |
50
49
| fullWidth |`bool`|`false`| If true, the chip input will fill the available width. |
51
50
| fullWidthInput |`bool`|`false`| If true, the input field will always be below the chips and fill the available space. By default, it will try to be beside the chips. |
52
-
| hintText |`node`|| The hint text to display. |
53
-
| id |`string`|_a unique id_| The id prop for the text field, should be set to some deterministic value if you use server-side rendering. |
51
+
| label |`node`|| The content of the floating label. |
54
52
| newChipKeyCodes |`number[]`|`[13]` (enter key) | The key codes used to determine when to create a new chip. |
55
53
| onBeforeRequestAdd |`function`|| Callback function that is called with the chip to be added and should return true to add the chip or false to prevent the chip from being added without clearing the text input. |
56
54
| onBlur |`function`|| Callback function that is called with `event` when the input loses focus, where `event.target.value` is the current value of the text input. |
57
55
| onChange |`function`|| Callback function that is called when the chips change (in uncontrolled mode). |
58
-
| onClick |`function`|| Callback function that is called when text input is clicked. |
59
56
| onRequestAdd |`function`|| Callback function that is called when a new chip was added (in controlled mode). |
60
57
| onRequestDelete |`function`|| Callback function that is called when a new chip was removed (in controlled mode). |
61
58
| onUpdateInput |`function`|| Callback function that is called when the input changes (useful for auto complete). |
62
59
| openOnFocus |`bool`|`false`| Opens the auto complete list on focus if set to true. |
63
-
|style|`object`||Override the inline-styles of the root element. |
60
+
|placeholder|`node`||A short placeholder that is displayed if the input has no values. |
64
61
| value |`string[]`|| The chips to display (enables controlled mode if set). |
65
62
66
63
67
-
Additionally, most other properties of Material UI's [Auto Complete][mui-auto-complete] and [Text Field][mui-text-field] should be supported. Please open an issue if something is missing or does not work as expected.
64
+
Any other properties supplied will be [spread to the root element](https://material-ui-next.com/guides/api/#spread). The properties of [<FormControl />](https://material-ui-next.com/api/form-control/) are also available.
65
+
66
+
## CSS API
67
+
You can customize the class names used by `ChipInput` with the `classes` property. It accepts the following keys:
68
+
*`root`
69
+
*`inputRoot`
70
+
*`input`
71
+
*`chipContainer`
72
+
*`label`
73
+
*`helperText`
74
+
*`chip`
75
+
76
+
Have a look at [this guide](https://material-ui-next.com/customization/overrides/#overriding-with-classes) for more detail.
68
77
69
78
## Credits
70
-
The code for the input component was adapted from Material UI's [Auto Complete][mui-auto-complete] and [Text Field][mui-text-field] that we all know and love.
79
+
The code for the input component was adapted from Material UI's [Text Field][mui-text-field] that we all know and love.
71
80
72
81
## License
73
82
The files included in this repository are licensed under the MIT license.
0 commit comments