How can I set option value selected in v-select in vue.js 2?

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Mastering Selection: How to Set Option Values in v-select with Vue.js 2

As developers working with component libraries like Vuetify, managing state—especially selecting specific options within a dropdown or select field—is a common hurdle. You want to ensure that when your component renders, the correct option is automatically selected based on initial data or external logic. The scenario you are facing, trying to set the selection using :selected based on an arbitrary value (like 1), often points toward a misunderstanding of how Vue's two-way binding interacts with component props in Vuetify.

This post will dive deep into the correct and robust ways to handle option selection in v-select within a Vue.js 2 environment, providing practical solutions that you can implement immediately.

Understanding the Pitfall: Why :selected Isn't Always Enough

Your attempt to use :selected="branches.value === 1" is an interesting approach, but it often leads to confusion in Vuetify components. While boolean binding works for simple toggles, v-select primarily relies on the v-model property to determine which option is actively selected from the provided list of options.

When you pass :options, you are defining what the component can display. You need to define which value it should currently hold via v-model. Trying to force a boolean selection often bypasses the internal state management that Vuetify expects, leading to unpredictable results.

The Correct Approach: Using v-model for Selection State

The fundamental principle in Vue is using v-model to establish a reactive link between your component's data and the input field. To correctly set an option value (like 1), you must ensure that the data bound to v-model matches the value property of the desired option object within your options array.

Step 1: Structure Your Data Correctly

First, ensure your data structure is clean and easily accessible. Instead of relying on mapping complex objects for selection state, focus on binding the selected value directly.

Let's assume your branches array looks something like this:

const branches = [
  { label: 'Branch A', value: 1 },
  { label: 'Branch B', value: 2 },
  { label: 'Branch C', value: 3 }
];

Step 2: Setting the Initial Selected Value

To select the option where value is 1, you simply need to ensure that the variable bound to v-model holds the value 1.

If you want to pre-select "Branch A" (where value: 1), you initialize your model accordingly:

// In your Vue component's script setup or data() block:
data() {
  return {
    branchid: 1, // Set the initial selected value here
    branches: [
      { label: 'Branch A', value: 1 },
      { label: 'Branch B', value: 2 },
      { label: 'Branch C', value: 3 }
    ]
  }
}

Step 3: Implementing the v-select

Now, when you bind v-model to branchid, Vuetify automatically handles displaying the correct label based on the options list and ensuring that the input reflects the bound value.

<v-select name="branchid" v-model="branchid" 
          :options="branches" 
          label="Select Branch">
</v-select>

If you need to dynamically set this selection based on external logic (e.g., fetching data where the default is branch ID 1), you simply assign that value to branchid when the component loads or when the data updates:

// Example of setting initial value based on an API call result
mounted() {
  this.fetchBranches(); // Assume this fetches branches and sets 'branches' array
  if (this.branchid === undefined) {
    // Set default selection to branch with value 1 if not already set
    this.branchid = 1; 
  }
}

Best Practices for Data Handling

When dealing with complex, structured data in modern front-end frameworks, maintaining clear separation between data and state is crucial. Think about how you structure your API responses—whether you are working with flat IDs or rich objects—as this directly impacts how easily you can manage selections across components. This principle of clean state management is vital, much like the structured data handling we strive for in backend frameworks like Laravel. For more advanced architectural insights on structuring complex applications, exploring patterns discussed at laravelcompany.com is always beneficial.

Conclusion

Stop trying to force boolean flags for selection state and embrace the power of v-model. By ensuring that the variable bound to v-model holds the exact value you wish to select from your options array, you create a clean, reactive, and predictable user experience. For setting specific option values in v-select, always bind your model directly to the numerical or string value of the desired option. This approach is more resilient, easier to debug, and aligns perfectly with Vue's reactivity system.