@gluedigital/autocomplete

A very simple autocomplete component for React

Stats

StarsIssuesVersionUpdatedCreatedSize
@gluedigital/autocomplete
1.4.12 years ago3 years agoMinified + gzip package size for @gluedigital/autocomplete in KB

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.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.