vue-select
Everything you wish the HTML <select> element could do, wrapped up into a lightweight, extensible Vue component.
Top Related Projects
Universal select/multiselect/tagging component for Vue.js
Vue drag-and-drop component based on Sortable.js
A lightweight Vue.js UI library with a simple API, inspired by Google's Material Design.
Quick Overview
Vue Select is a feature-rich, flexible select component for Vue.js. It provides a customizable dropdown interface for selecting single or multiple options, with support for searching, tagging, and asynchronous loading of options.
Pros
- Highly customizable with numerous props and slots
- Supports both single and multiple selections
- Includes built-in search functionality
- Offers asynchronous option loading for large datasets
Cons
- Learning curve for advanced customization
- May be overkill for simple select needs
- Some users report performance issues with large datasets
- Documentation could be more comprehensive for complex use cases
Code Examples
Basic usage:
<template>
<v-select v-model="selected" :options="options"></v-select>
</template>
<script>
import vSelect from 'vue-select'
export default {
components: { vSelect },
data() {
return {
selected: null,
options: ['foo', 'bar', 'baz']
}
}
}
</script>
Multiple selection with objects:
<template>
<v-select multiple v-model="selected" :options="options" label="name"></v-select>
</template>
<script>
import vSelect from 'vue-select'
export default {
components: { vSelect },
data() {
return {
selected: [],
options: [
{ name: 'John', id: 1 },
{ name: 'Jane', id: 2 },
{ name: 'Bob', id: 3 }
]
}
}
}
</script>
Asynchronous option loading:
<template>
<v-select label="name" :options="options" @search="onSearch"></v-select>
</template>
<script>
import vSelect from 'vue-select'
export default {
components: { vSelect },
data() {
return {
options: []
}
},
methods: {
onSearch(search, loading) {
loading(true)
this.search(loading, search, this)
},
search: _.debounce((loading, search, vm) => {
fetch(`https://api.github.com/search/users?q=${search}`)
.then(res => res.json())
.then(json => {
vm.options = json.items
loading(false)
})
}, 350)
}
}
</script>
Getting Started
-
Install vue-select:
npm install vue-select
-
Import and use in your Vue component:
<template> <v-select v-model="selected" :options="options"></v-select> </template> <script> import vSelect from 'vue-select' import 'vue-select/dist/vue-select.css' export default { components: { vSelect }, data() { return { selected: null, options: ['Option 1', 'Option 2', 'Option 3'] } } } </script>
-
For global registration, add to your main.js:
import Vue from 'vue' import vSelect from 'vue-select' import 'vue-select/dist/vue-select.css' Vue.component('v-select', vSelect)
Competitor Comparisons
Universal select/multiselect/tagging component for Vue.js
Pros of vue-multiselect
- More feature-rich, offering advanced functionalities like grouping, custom option rendering, and tagging
- Better out-of-the-box styling and customization options
- Actively maintained with frequent updates and bug fixes
Cons of vue-multiselect
- Slightly larger bundle size due to additional features
- Steeper learning curve for beginners due to more complex API
Code Comparison
vue-multiselect:
<template>
<multiselect v-model="value" :options="options" :multiple="true" :close-on-select="false" placeholder="Pick some">
</template>
<script>
import Multiselect from 'vue-multiselect'
export default {
components: { Multiselect },
data () {
return {
value: [],
options: ['List', 'of', 'options']
}
}
}
</script>
vue-select:
<template>
<v-select multiple v-model="selected" :options="options"></v-select>
</template>
<script>
import vSelect from 'vue-select'
export default {
components: { vSelect },
data() {
return {
selected: [],
options: ['List', 'of', 'options']
}
}
}
</script>
Both libraries offer similar basic functionality, but vue-multiselect provides more built-in features and customization options out of the box. vue-select, on the other hand, has a simpler API and may be easier for beginners to implement quickly.
Vue drag-and-drop component based on Sortable.js
Pros of Vue.Draggable
- Provides drag-and-drop functionality, allowing for interactive list reordering
- Integrates well with existing Vue.js applications and components
- Supports touch devices and various drag-and-drop use cases
Cons of Vue.Draggable
- More complex to set up and configure compared to vue-select
- May have a steeper learning curve for developers new to drag-and-drop functionality
- Limited to list manipulation, whereas vue-select focuses on dropdown selection
Code Comparison
Vue.Draggable:
<draggable v-model="myArray" group="people" @start="drag=true" @end="drag=false">
<div v-for="element in myArray" :key="element.id">{{ element.name }}</div>
</draggable>
vue-select:
<v-select v-model="selected" :options="options"></v-select>
Vue.Draggable is designed for creating draggable and sortable lists, while vue-select is focused on providing a flexible and customizable select input component. Vue.Draggable requires more setup but offers advanced list manipulation features, whereas vue-select is simpler to implement but limited to dropdown functionality. The choice between these two depends on the specific requirements of your project and the desired user interaction.
A lightweight Vue.js UI library with a simple API, inspired by Google's Material Design.
Pros of Keen-UI
- Offers a comprehensive set of UI components beyond just select inputs
- Provides a consistent design language across all components
- Includes accessibility features out-of-the-box
Cons of Keen-UI
- Larger bundle size due to the full component library
- May require more setup and configuration for individual components
- Less focused on select functionality compared to vue-select
Code Comparison
Keen-UI select component usage:
<ui-select
v-model="selectedValue"
:options="options"
label="Select an option"
></ui-select>
vue-select component usage:
<v-select
v-model="selectedValue"
:options="options"
label="Select an option"
></v-select>
Both libraries offer similar basic usage for select components, with slight differences in component naming conventions. Keen-UI uses the ui-select
prefix, while vue-select uses v-select
.
Keen-UI provides a more extensive set of UI components, making it suitable for projects requiring a complete UI framework. However, this comes at the cost of a larger bundle size and potentially more complex setup.
vue-select, on the other hand, focuses specifically on select functionality, offering a lighter-weight solution for projects that only need a robust select component. It may be easier to integrate into existing projects without introducing unnecessary dependencies.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
vue-select
Everything you wish the HTML
<select>
element could do, wrapped up into a lightweight, zero dependency, extensible Vue component.
Vue Select is a feature rich select/dropdown/typeahead component. It provides a default template that fits most use cases for a filterable select dropdown. The component is designed to be as lightweight as possible, while maintaining high standards for accessibility, developer experience, and customization.
- Tagging
- Filtering / Searching
- Vuex Support
- AJAX Support
- SSR Support
- Accessible
- ~20kb Total / ~5kb CSS / ~15kb JS
- Select Single/Multiple Options
- Customizable with slots and SCSS variables
- Zero dependencies
Documentation
Complete documentation and examples available at https://vue-select.org.
Sponsors :tada:
It takes a lot of effort to maintain this project. If it has saved you development time, please consider sponsoring the project with GitHub sponsors!
Huge thanks to the sponsors and contributors that make Vue Select possible!
Get started
Vue 3 / Vue Select 4.x-beta
Vue 3 support is on the
beta
channel:vue-select@beta
, and will become the new default whenv4
is released. See #1579 for more details!
Install:
yarn add vue-select@beta
# or use npm
npm install vue-select@beta
Then, import and register the component:
# main.ts or main.js
import { createApp } from "vue";
import App from "./App.vue";
import { VueSelect } from "vue-select";
createApp(App)
.component("v-select", VueSelect)
.mount("#app");
The component itself does not include any CSS. You'll need to include it separately in your Component.vue:
<style>
@import "vue-select/dist/vue-select.css";
</style>
Vue 2 / Vue Select 3.x
Install:
yarn add vue-select
# or use npm
npm install vue-select
Then, import and register the component:
import Vue from "vue";
import vSelect from "vue-select";
Vue.component("v-select", vSelect);
The component itself does not include any CSS. You'll need to include it separately:
import "vue-select/dist/vue-select.css";
You can also include vue-select directly in the browser. Check out the documentation for loading from CDN..
License
Top Related Projects
Universal select/multiselect/tagging component for Vue.js
Vue drag-and-drop component based on Sortable.js
A lightweight Vue.js UI library with a simple API, inspired by Google's Material Design.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot