1010
1111> WAI-ARIA compliant React autocomplete component
1212
13+ ### Demo
14+ https://jfusco.github.io/react-predictive-input
15+
16+ ## Getting Started ##
17+
18+ #### Installation
19+ From the root of your project.
20+ ``` sh
21+ npm install react-predictive-input --save
22+ ```
23+
1324## Usage
1425Implementation of autocomplete. See [ available options] ( #options ) below.
1526``` js
1627import React , { Component } from ' react' ;
1728import { render } from ' react-dom' ;
18- import Autocomplete from ' react-autocomplete ' ;
29+ import Autocomplete from ' react-predictive-input ' ;
1930
2031class Application extends Component {
32+ static defaultProps = {
33+ fruit: [' bananas' , ' strawberries' , ' blueberries' , ' pineapples' , ' apples' , ' tomatos' , ' mangos' , ' oranges' , ' grapes' , ' Rasberries' , ' Blackberries' , ' starfruit' ]
34+ };
35+
36+ static propTypes = {
37+ fruit: PropTypes .arrayOf (PropTypes .string )
38+ };
39+
2140 constructor (props ){
2241 super (props);
23-
24- this .fruit = [' bananas' , ' strawberries' , ' blueberries' , ' pineapples' , ' apples' , ' tomatos' , ' mangos' , ' oranges' , ' grapes' , ' Rasberries' , ' Blackberries' , ' starfruit' ];
2542 }
2643
2744 onItemSelected (value ){
@@ -32,9 +49,10 @@ class Application extends Component{
3249 return (
3350 < div>
3451 < Autocomplete
35- id= " 1"
36- placeholder= " Fruits"
37- onSelected= {this .onItemSelected .bind (this )} / >
52+ id= " fruit"
53+ placeholder= " Search a type of fruit"
54+ data= {this .props .fruit }
55+ onSelected= {:: this .onItemSelected )} / >
3856 < / div>
3957 );
4058 }
@@ -59,14 +77,14 @@ render(<Application />, document.getElementById('application'));
5977##### id ~ required
6078The unique ` id ` of the component - used for setting up accessibility
6179``` js
62- < Autocomplete id= " 1 " / >
80+ < Autocomplete id= " fruit " / >
6381```
6482
6583<a name =" placeholder " ></a >
6684##### placeholder ~ optional ~ default ` null `
6785A ` string ` used as placeholder text in the tags input field
6886``` js
69- < Autocomplete placeholder= " Fruits " / >
87+ < Autocomplete placeholder= " Search a type of fruit " / >
7088```
7189
7290<a name =" data " ></a >
@@ -130,7 +148,7 @@ onItemSelected(value) {
130148#### Installation
131149Import the main SCSS file in to your application SCSS files
132150``` scss
133- @import " src/scss/components/react-autocomplete " ;
151+ @import " node_modules/react-predictive-input/ src/component/ scss/styles.scss " ;
134152```
135153
136154There are a few variables set to ` !default ` that can be overriden. If you need to change it more just override the actual styles.
@@ -176,7 +194,7 @@ $ac-s-padding
176194
177195If you don't care to override variables and just want to override actual styles you may choose to import the minified compiled version of the css instead
178196``` scss
179- @import " dist /react-autocomplete.min .css" ;
197+ @import " node_modules /react-predictive-input/dist/styles .css" ;
180198```
181199
182200## Tests ##
0 commit comments