All Projects → ejmudi → React Autocomplete Hint

ejmudi / React Autocomplete Hint

Licence: mit
A React component for Autocomplete Hint.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Autocomplete Hint

autocompletex
redis autocomplete for elixir
Stars: ✭ 22 (-83.21%)
Mutual labels:  autocomplete, typeahead
Vue Autosuggest
🔍 Vue autosuggest component.
Stars: ✭ 492 (+275.57%)
Mutual labels:  autocomplete, typeahead
Autocomplete
Accessible autocomplete component for vanilla JavaScript and Vue.
Stars: ✭ 277 (+111.45%)
Mutual labels:  autocomplete, typeahead
ng-sq-ui
Flexible and easily customizable UI-kit for Angular 11+
Stars: ✭ 99 (-24.43%)
Mutual labels:  autocomplete, typeahead
Autosuggest Trie
Minimalistic trie implementation for autosuggest and autocomplete components
Stars: ✭ 22 (-83.21%)
Mutual labels:  autocomplete, typeahead
vue-single-select
single select dropdown with autocomplete
Stars: ✭ 43 (-67.18%)
Mutual labels:  autocomplete, typeahead
Accessible Autocomplete
An autocomplete component, built to be accessible.
Stars: ✭ 474 (+261.83%)
Mutual labels:  autocomplete, typeahead
react-abstract-autocomplete
Bring-Your-Own-UI autocomplete / mentions component for React.
Stars: ✭ 15 (-88.55%)
Mutual labels:  autocomplete, typeahead
React Autosuggest
WAI-ARIA compliant React autosuggest component
Stars: ✭ 5,773 (+4306.87%)
Mutual labels:  autocomplete, typeahead
Zsh Autocomplete
🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
Stars: ✭ 641 (+389.31%)
Mutual labels:  autocomplete, typeahead
vue-thailand-address
🇹🇭 Thai address input for Vue.
Stars: ✭ 44 (-66.41%)
Mutual labels:  autocomplete, typeahead
React Input Enhancements
Set of enhancements for input control
Stars: ✭ 1,375 (+949.62%)
Mutual labels:  autocomplete, typeahead
extensions
Angular Material Extensions Library.
Stars: ✭ 203 (+54.96%)
Mutual labels:  autocomplete, typeahead
svelecte
Selectize-like component written in Svelte, also usable as custom-element 💪⚡
Stars: ✭ 121 (-7.63%)
Mutual labels:  autocomplete, typeahead
instatype
⚡️ Mobile-friendly React autocomplete component
Stars: ✭ 48 (-63.36%)
Mutual labels:  autocomplete, typeahead
Svelte Select
A select component for Svelte apps
Stars: ✭ 414 (+216.03%)
Mutual labels:  autocomplete, typeahead
indicium
🔎 A simple in-memory search for collections and key-value stores.
Stars: ✭ 41 (-68.7%)
Mutual labels:  autocomplete, typeahead
react-thailand-address-typeahead
jquery.Thailand.js in React
Stars: ✭ 78 (-40.46%)
Mutual labels:  autocomplete, typeahead
Jquery Typeahead
Javascript Typeahead (autocomplete) plugin with more than 50 options and callbacks.
Stars: ✭ 527 (+302.29%)
Mutual labels:  autocomplete, typeahead
Bootstrap 4 Autocomplete
A simple autocomplete/typeahead for Bootstrap 4 and jQuery
Stars: ✭ 36 (-72.52%)
Mutual labels:  autocomplete, typeahead

react-autocomplete-hint

A React component for Autocomplete Hint.

NPM npm Build Status codecov

Demo

Demo can be found here: https://ejmudi.github.io/react-autocomplete-hint/

Installation

npm install --save react-autocomplete-hint

or

yarn add react-autocomplete-hint

Usage

import { Hint } from 'react-autocomplete-hint';

const options = ["orange", "banana", "apple"];

// OR

const options = [
    {id: 1, label: "orange"}, 
    {id: '2', label: "banana"}, 
    {id: 3, label: "apple"}
];

<Hint options={options}>
    <input
        value={text}
        onChange={e => setText(e.target.value)} />
</Hint>

Click on the hint or use your keyboard Right key or Tab key(if allowTabFill is set to true) to fill your input with the suggested hint.

Props

options (required): Array<string> | Array<object>

disableHint (optional): Boolean

allowTabFill (optional): Boolean

onFill (optional): (value: string | object)=> void

valueModifier (optional): (value: string)=> string

object option

If you're using objects for your options. object schema is as follows:

id: string | number

label: string

onFill

Returns the option selected immediately the input is filled with the suggested hint.

Note that it won't return the selected option with the casing the user typed, rather it returns the option with the casing specified in your options prop. For example, if the options are specified like this:...

const options = ["orange", "banana", "apple"];

...and the input gets filled with "ORange", onFill will still return "orange".

valueModifier

This prop accepts a function that modifies your input value before it is saved in state.

It is typically useful when you are not setting e.target.value directly in state and need to modify the target value to some other value first before setting it in state.

Example: A case where you need to set the input value to uppercase irrespective of the casing the user types in:

const options = ["orange", "banana", "apple"];

const modifyValue = (value: string) => value.toUpperCase();

<Hint options={options} valueModifier={modifyValue}>
    <input
        value={text}
        onChange={e => setText(modifyValue(e.target.value))} />
</Hint>

Note: Not setting the valueModifier prop in cases like this might result to a malformed hint.

Duplicate data

If you are using objects for your options, You may have unexpected results if your data options contain objects with duplicate labels. For this reason, it is highly recommended that you pass in objects with unique labels if possible.

For example, if you pass in optionsWithDuplicateLabels as seen below and you then fill the input with the orange hint, the orange will be the first orange object found in the array as can be seen in the onFill prop:

const optionsWithDuplicateLabels = [
    {id: "1", label: "orange"},
    {id: "2", label: "orange"},
    {id: "3", label: "banana"}
];

<Hint options={optionsWithDuplicateLabels} onFill={value=> {
    // will always log {id: "1", label: "orange"} when orange is selected
    // {id: "2", label: "orange"} will never be logged.
    console.log(value);
}}>
    <input
        value={text}
        onChange={e => setText(e.target.value)} />
</Hint>

License

MIT

Inspired by React Bootstrap Typeahead.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].