svelte-autocomplete-input
v1.0.2
Published
Svelte Autocomplete input
Downloads
47
Maintainers
Readme
Auto Complete Input
Autocomplete input made with Svelte.
Install
npm install -D svelte-autocomplete-input
Usage
Import the component and define items:
import AutoCompleteInput from "svelte-autocomplete-input"
const colors = ["White", "Red", "Yellow", "Green", "Blue", "Black"];
function handleChange(event: ComponentEvents<AutoCompleteInput>['onChangeValue']): void {
console.log(event.detail);
}
<AutoCompleteInput
name="color"
placeholder="Colors"
items={colors}
on:onChangeValue={handleChange}
/>
Can be used with tailwindcss.
<AutoCompleteInput
name="color"
placeholder="Colors"
items={colors}
on:onChangeValue={handleChange}
inputClass="rounded border p-3"
itemClass="border border-t-0 py-3 px-2 text-left"
/>
Properties
items
- array of items the user can select fromplaceholder
- placeholder of the input tagdefaultValue
- default valuesearchMode
- "include" | "start". default("start")name
- name of the input tagcontainerClass
- container classinputClass
- input classitemClass
- item classcontainerStyle
- container styleinputStyle
- input styleitemStyle
- item styleitemBackColor
- item background color. default(#ffffff)itemColor
- item text color. default(#000000)selectedItemBackColor
- selected item background color. default(#000000)selectedItemColor
- selected item text color. default(#ffffff)