1.0.5 • Published 2 years ago

vue3-typeahead-input v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vue3-typeahead-input

A simple Vue 3 type-ahead input component that shows a list of suggested items based on the user input

Demo

Installation

Using npm

npm install vue3-typeahead-input

Using yarn

yarn add vue3-typeahead-input

Usage

Import vue3-typeahead-input component globally. You can import default CSS of the component if you want.

import App from './App.vue';
import TypeaheadInput from 'vue3-typeahead-input';
import 'vue3-typeahead-input/dist/style.css'; //Optional default CSS

let app = createApp(App)
app.component('TypeaheadInput', TypeaheadInput)
app.mount('#app')

...Or import vue3-typeahead-input component locally in component you want.

import TypeaheadInput from 'vue3-typeahead-input'
import 'vue3-typeahead-input/dist/style.css'; //Optional default CSS

export default {
    name: 'YourComponentName',
    components: {
        TypeaheadInput
    }
}

Use component in template

<template>
    <div>
        <TypeaheadInput
            :items="items"
            v-model="selectedItem">
        </TypeaheadInput>    
    </div>
</template>

<script setup>
    import { ref } from 'vue';
    
    const items = [
        {
            text:'Item 1',
            value: 'item-1'
        },
        {
            text:'Item 2',
            value: 'item-2'
        },
        {
            text:'Item 3',
            value: 'item-3'
        },
    ]
    const selectedItem = ref('item-3')
</script>

Properties

PropertyTypeDescriptionDefault
itemsArrayAn array of objects or array of primary types like string or number. It will look for a text and value keys. This can be changed using the item-text, item-value[]
item-textstringSet property of items’s text valuetext
item-valuestringSet property of items’s value. In case skip-item-value is true the value will be used to set option item keyvalue
skip-item-valuebooleanGet whole object item as a value
labelstringLabel of typeahead inputundefined
valueanyValue of typeahead inputundefined
readonlybooleanSet state of input is readonlyundefined
disabledbooleanSet state of input is disabled, it's similar to readonly props but has different styleundefined
valueanyValue of typeahead inputundefined
emptyMessagestringDisplay message when there is no dataNo data available

Fallthrough attributes

All attributes added to the component not provided above fallthrough the input control. For example, placeholder, maxlength... or input events @input, @focus...Check out more details at the demo

Events

NameDescription
@changeEmitted when the input is changed by user interaction
@update:modelValueThe updated bound model

Slot

NameDescription
option-itemDefine a custom option item appearance v-slot:option-item={item, value}

Exposed

NameDescription
inputInput element
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago