autocomplete-react-v2
v2.0.2
Published
Customizable Autocomplete input component for react
Downloads
21
Readme
How to use
1. Install
$ npm install autocomplete-react-v2
2. Import
import { Autocomplete } from 'autocomplete-react-v2'
4. Example
import React, { Component } from 'react';
import { Autocomplete } from 'autocomplete-react-v2';
const COUNTRIES = [
'Afghanistan',
'Aland Islands',
'Albania',
'Algeria',
'American Samoa',
'Andorra',
'Angola',
'Anguilla',
];
export default function Example() {
const onOptionSelected = (value) => {
console.log(value);
};
return (
<Autocomplete
words={COUNTRIES}
placeholder="Type something..."
onOptionSelected={onOptionSelected}
showOnFocus={true}
hideOnBlur={true}
/>
);
}
5. Properties
| Property | Type | Default | Description | | --- | --- | --- | --- | | words | array | [] | Array of words to be used for autocomplete | | placeholder | string | "" | Placeholder text for input | | onOptionSelected | function | () => {} | Callback function when option is selected | | containerStyle | object | {} | Style object for container | | inputStyle | object | {} | Style object for input | | completionTextStyle | object | {} | Style object for completion text | | completionListStyle | object | {} | Style object for completion list | | showOnFocus | boolean | false | Show completion list on input focus | | hideOnBlur | boolean | false | Hide completion list on input blur |