@gluedigital/autocomplete
v1.4.1
Published
A very simple autocomplete component for React
Downloads
3
Keywords
Readme
Autocomplete
A very simple autocomplete component with no dependencies.
Usage
To install it:
npm install --save @gluedigital/autocomplete
To use it:
import Autocomplete from '@gluedigital/autocomplete'
import '@gluedigital/autocomplete/css/autocomplete.css'
const values = ['Alice', 'Bob', 'Carol']
// ...
<form>
<Autocomplete values={values} name="my-field-name" required />
</form>
Options
The following props can be used:
| Name | Type | Description | |------|------|-------------| | name | string | The name to use on the internal input | | values | array | The allowed values | | valueLabel | string or function | If the values are not strings, the field to use as label, or a function to generate it | | required | bool | Whether the input should have the required flag | | autoFocus | bool | Whether the input should have the autoFocus flag | | noResultsText | string | A message for the dropdown when there are no results | | placeholder | string | A placeholder shown when the input is empty | | value | string | The preselected value | | onChange | func | A function that will be called when the selection changes | | withClear | bool | Whether to show a clear button |
Developing
This package uses nwb for the build. Take a look at their documentation for more info.
TL;DR: after installing nwb, just do npm start
to open the dev environment.