Skip to content

ExAutocomplete

html
<ExAutocomplete
    v-model="initialValue"
    v-model:state="dropdownState"
    v-slot="{ isOpen }"
    matchKey="value"
>
    <div>
        <ExAutocompleteInput
            :displayValue="displayValues"
            @change="fnSearch"
        />
        <span>&#8963;</span>
    </div>
    <ExAutocompleteList>
        <template v-for="(item) in filteredList" :key="list.value">
            <ExAutocompleteListItem
                :value="item"
                v-slot="{ active, isSelected }"
            >
                <div>
                    <span>{{ item.text }}</span>
                    <span v-if="isSelected" class="text-base text-green-400">&#10003;</span>
                </div>
            </ExAutocompleteListItem>
        </template>
    </ExAutocompleteList>
</ExAutocomplete>

Interact

Props: ExAutocomplete

as

TypeDefaultRequired
string componenttemplatefalse

Description: Sets the element type of ex-autocomplete. Any custom vue component can also be passed.


v-model

TypeDefaultRequired
array string objectundefinedfalse

Description: Takes an initial value to be displayed in the input


v-model:state

TypeDefaultRequired
booleanfalsefalse

Description: Determines state of the dropdown list. Pass on boolean value to control the visibility.


multiple

TypeDefaultRequired
booleanfalsefalse

Description: If true, it allows multiple values to be selected from the dropdown list.


clearable

TypeDefaultRequired
booleanfalsefalse

Description: If true, selected value will be cleared once the input field is cleared. If false, selected value will be re-applied when the input is focused out even if the input was cleared earlier.


disabled

TypeDefaultRequired
booleanfalsefalse

Description: Enable/Disable ex-autocomplete


closeOnClick

TypeDefaultRequired
booleantruefalse

Description: Choose whether dropdown should be closed on content click


matchKey

TypeDefaultRequired
string functionundefinedtrue, if list item is an object, else false

Description: A match key which represents a unique key of the list item. This helps in filtering and setting up active and isSelected states.


TypeDefaultRequired
booleanfalsefalse

Description: Positions dropdown list to the right of the input


left

TypeDefaultRequired
booleanfalsefalse

Description: Positions dropdown list to the left of the input


Emits

NameDescription

update:modelValue

This v-model update gets emitted when any value is selected from the list

html
<div v-model="initialValue" ...>
    ...
</div>

update:state

This v-model update is emits when any value is selected from the list

html
<div v-model:state="visibility" ...>
    ...
</div>

Slots

NameDescription

default

The default Vue slot.

js
{
    open: Function, // opens dropdown
    close: Function, // closes dropdown
    isOpen: boolean,
    labelAttrs: {
        id: string, // element ID will be set automatically
        for: string // refers to autocomplete-input-id
    }
}

Props: ExAutocompleteInput

as

TypeDefaultRequired
string componentinputfalse

Description: Sets the element type of ex-autocomplete-input. Any custom vue component can also be passed.


displayValue

TypeDefaultRequired
Functionundefinedtrue

Description: This accepts a function. Selected value is passed as the single argument.

Example:

html
<ExAutocompleteInput
    class="w-full px-3 outline-none"
    :displayValue="(item) => item.text"
>
</ExAutocompleteInput>

Slots

NameDescription
defaultThe default Vue slot

Props: ExAutocompleteList

as

TypeDefaultRequired
string componenttemplatefalse

Description: Sets the element type of ex-dropdown-trigger. Any custom vue component can also be passed.


disabled

TypeDefaultRequired
booleanfalsefalse

Description: Enables / Disables dropdown trigger.


minWidth

TypeDefaultRequired
string numberWidth of the triggerfalse

Description: Sets the min-width of ex-dropdown-list. Values can also be percentages.


maxWidth

TypeDefaultRequired
string numberundefinedfalse

Description: Sets the max-width of ex-dropdown-list. Values can also be percentages.


maxHeight

TypeDefaultRequired
string numberundefinedfalse

Description: Sets the max-height of ex-dropdown-list. Values can also be percentages.


Slots

NameDescription

default

The default Vue slot.

js
{
    isOpen: boolean
}

Props: ExAutocompleteListItem

as

TypeDefaultRequired
string componentdivfalse

Description: Sets the element type of ex-dropdown-list-item. Any custom vue component can also be passed.


disabled

TypeDefaultRequired
booleanfalsefalse

Description: Enables / Disables dropdown list item.


Slots

NameDescription

default

The default Vue slot.

js
{
    active: boolean
    disabled: boolean
}

Released under the MIT License.