React autocomplete component built with Downshift
Composable React autocomplete component built with [Downshift][]
``sh`
npm i pcln-autocomplete
`jsx
import React from 'react'
import { Autocomplete } from 'pcln-autocomplete'
import { Icon, Text } from 'pcln-design-system'
export default props =>
onChange={item => {
props.onChange(item)
}}>
Location
{props.locations.map(location => (
item={location}>
mr={2}
color='blue'
/>
{location.name}
))
`
_Note: relies on values from theme, so it must be a descendent of in order to work properly. Otherwise, you might experience errors like this:_
``
Uncaught TypeError: Cannot read property '3' of undefined
All components can be imported by name and subcomponents are provided as static properties on the Autocomplete component.
Wrapper for Downshift component with additional match prop.
| Prop | Type | Description |
| -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| match | function | Filters direct children of the Menu component |itemToString
| | function | Used to determine the string value for the selected item (shown in the input value) |onChange
| | function | Called when the user selects an item and the selected item has changed. Called with the item that was selected and the new state of downshift |
For additional props, see the [Downshift documentation][downshift].
Design system Label component with additional default props provided by Downshift for accessibility.
Design system Input component with additional default props provided by Downshift for accessibility.
Design system Card component with styles and default props to work with Downshift.
Design system Flex component with styles and default props to work with Downshift.
- [ ] Make autocomplete elements compatible with design system FormField`
[downshift]: https://github.com/paypal/downshift