Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A lightweight typeahead / autocomplete component made with Svelte.js

License

NotificationsYou must be signed in to change notification settings

elcobvg/svelte-autocomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lightweight typeahead / autocomplete component made withSvelte.js

  • no dependencies
  • can handle asynchronous data
  • use plain lists or key / value pairs

Install

npm install svelte-autocomplete

Usage

Import the component directly in your Svelte project.

importAutoCompletefrom'svelte-autocomplete'exportdefault{components:{    AutoComplete,...}}

And then use it like so:

<AutoCompleteclass="input"name="fruits"items="{fruits}"minChar="1"/><AutoCompletename="countries"items="{countries}"isAsyncon:input="loadApiData(event)"><divclass="notification">Loading data from API...</div></AutoComplete>

Options

PropTypeDefaultDescription
nameString-Form input name
classString-Additional styles for input element
itemsArray-Array with items, can be a plain list or key, value pairs
isAsyncBooleanfalseIf retrieving API data asynchronously
minCharNumber2Min. characters to type before popup shows
maxItemsNumber10Max. items to show in popup
fromStartBooleantrueMatch from the start or anywhere in the string

Slots

SlotProp dependenciesDescription
defaultisAsynccustom loading indication

Made with Svelte

It's made withSvelte, which means you don't need any JS framework. Just use thedist/index.js file in any Javascript project:

include the bundle:

<scriptsrc="svelte-autocomplete/dist/index.js"></script>

create component like so:

constmyComponent=newAutoComplete({target:document.querySelector('#app'),data:{name:'fruits',itemStart:1,items:[...]}})

About

A lightweight typeahead / autocomplete component made with Svelte.js

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp