How to handle select dropdown in Vue

Creating select dropdowns is fundamental for building user-friendly forms and filtering interfaces in Vue applications. As the creator of CoreUI, a widely used open-source UI library, I’ve implemented countless dropdown components and form controls over 25 years of development. From my expertise, the most effective approach is using v-model with the select element and v-for to generate options dynamically from data arrays. This creates reactive dropdowns that automatically update when data changes and provide seamless two-way binding.

Use v-model with select element and v-for to create reactive dropdown menus.

<template>
  <select v-model="selectedCountry">
    <option disabled value="">Choose a country</option>
    <option v-for="country in countries" :key="country.code" :value="country.code">
      {{ country.name }}
    </option>
  </select>
</template>

<script>
export default {
  data() {
    return {
      selectedCountry: '',
      countries: [
        { code: 'US', name: 'United States' },
        { code: 'CA', name: 'Canada' }
      ]
    }
  }
}
</script>

Here v-model="selectedCountry" creates two-way binding between the select element and the data property. The v-for directive generates option elements from the countries array, using :key for Vue’s reactivity and :value to set the option values. The disabled placeholder option provides user guidance when no selection is made.

Best Practice Note:

This is the same dropdown implementation pattern we use in CoreUI Vue components for consistent form controls. Always provide a disabled placeholder option for better UX, use meaningful key attributes for option elements, and consider implementing search functionality for long option lists.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
CSS Selector for Parent Element
CSS Selector for Parent Element

Understanding the Difference Between NPX and NPM
Understanding the Difference Between NPX and NPM

How to Add a Tab in HTML
How to Add a Tab in HTML

Understanding and Resolving the “React Must Be in Scope When Using JSX
Understanding and Resolving the “React Must Be in Scope When Using JSX

Answers by CoreUI Core Team