@react-md/autocomplete
TypeScript icon, indicating that this package has built-in type declarations

5.1.6 • Public • Published

@react-md/autocomplete

Create an accessible autocomplete component that allows a user to get real-time suggestions as they type within an input. This component can also be hooked up to a backend API that handles additional filtering or sorting.

Installation

npm install --save @react-md/autocomplete

Documentation

You should check out the full documentation for live examples and more customization information, but an example usage is shown below.

Usage

The AutoComplete component just requires:

  • an id to identify the field (required for a11y)
  • a list of data that can be a list of string, number, or object

However, it is recommended to also provide a label and placeholder text to help the user understand this component.

import { AutoComplete } from "@react-md/autocomplete";

const fruits = [
  "Apple",
  "Apricot",
  "Banana",
  "Blueberry",
  "Cranberry",
  "Kiwi",
  "Peach",
  "Plum",
  "Strawberry",
];

function Example() {
  return (
    <AutoComplete
      id="search-fruits"
      name="fruits"
      label="Fruits"
      placeholder="Kiwi..."
      data={fruits}
    />
  );
}

Package Sidebar

Install

npm i @react-md/autocomplete

Weekly Downloads

1,099

Version

5.1.6

License

MIT

Unpacked Size

185 kB

Total Files

46

Last publish

Collaborators

  • mlaursen