Vue Multiselect Component

3.5.0 · active · verified Sun Apr 19

Vue Multiselect is a versatile, dependency-free multiselect and tagging component designed for Vue 3 applications. Currently at version 3.5.0, it offers a wide range of features including single and multiple selection, tagging capabilities, filtering, search with suggestions, and asynchronous option loading. The library maintains a steady release cadence with frequent bug fixes and minor feature enhancements, as seen in its recent 3.x releases. A key differentiator is its minimal footprint and explicit lack of external runtime dependencies, making it a lightweight choice. It supports Vue's `v-model`, Vuex integration, and fully configurable props for extensive customization. The component ships with TypeScript types, ensuring a robust developer experience for TypeScript users.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to set up Vue Multiselect with multiple selection, tagging, and options managed using Vue 3's Composition API.

<template>
  <div>
    <VueMultiselect
      v-model="selectedItem"
      :options="availableOptions"
      :multiple="true"
      :taggable="true"
      @tag="addOptionTag"
      tag-placeholder="Add as new tag"
      placeholder="Type to search or add tag"
      label="name"
      track-by="code">
    </VueMultiselect>
    <p>Selected: {{ selectedItem }}</p>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import VueMultiselect from 'vue-multiselect';
import 'vue-multiselect/dist/vue-multiselect.css';

interface Option {
  name: string;
  code: string;
}

export default defineComponent({
  components: { VueMultiselect },
  setup() {
    const selectedItem = ref<Option[]>([
      { name: 'Apple', code: 'AP' }
    ]);
    const availableOptions = ref<Option[]>([
      { name: 'Apple', code: 'AP' },
      { name: 'Banana', code: 'BN' },
      { name: 'Cherry', code: 'CH' }
    ]);

    const addOptionTag = (newTag: string) => {
      const tag: Option = {
        name: newTag,
        code: newTag.substring(0, 2).toUpperCase() + Math.floor(Math.random() * 10000000)
      };
      availableOptions.value.push(tag);
      selectedItem.value.push(tag);
    };

    return {
      selectedItem,
      availableOptions,
      addOptionTag
    };
  }
});
</script>

<style>
/* Optional: Adjust global styles if needed */
</style>

view raw JSON →