input-autocomplete
Version:
Tiny react input component with HTML5-like autocomplete.
57 lines (43 loc) • 1.27 kB
Markdown
Tiny react input component with HTML5-like autocomplete.

Because HTML5 autocomplete only show options based on earlier user typed values.
- Autocomplete based only on given values.
- No styling. Style it yourself as a regular text input element.
- Tiny abstraction over input element.
- Typescript types.
Live demo: [kevinjhanna.github.io/input-autocomplete](https://kevinjhanna.github.io/input-autocomplete/)
```
npm install input-autocomplete --save
```
```jsx
import { InputAutocomplete } from 'input-autocomplete'
<InputAutocomplete
type='text'
autocompleteValues={['john lennon', 'john travolta']}
/>
```
```jsx
import { InputAutocomplete } from 'input-autocomplete'
let state = {
name: ''
}
const handleOnChange = (ev) => {
state = {
name: ev.currentTarget.value
}
}
<InputAutocomplete
type='text'
autocompleteValues={['john lennon', 'john travolta']}
value={state.name}
onChange={handleOnChange}
/>
```