@gluedigital/autocomplete

1.4.1 • Public • Published

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.

/@gluedigital/autocomplete/

    Package Sidebar

    Install

    npm i @gluedigital/autocomplete

    Weekly Downloads

    9

    Version

    1.4.1

    License

    MIT

    Unpacked Size

    14.5 kB

    Total Files

    5

    Last publish

    Collaborators

    • linuxgunter
    • landesag
    • csar
    • mancontr
    • alex_bf
    • javibt