Component display based on v-select option in Vuetify, Vue and Typescript

Salifyanji Taala
3 min readOct 10, 2020

In this post am going to share with you how you can display a component based on the option selected using the v-select in Vuetify, Vue and Typescript.

We are going to start with creating a v-select and bind items to items array which we are going to create in Typescript

A vuetify v-select component

After we have created our v-select component, we want to display a red button when the option red is selected and the green button when selected. So we are going to declare an array called items holding button options.

Items Array holding button names

The front end results will show like the snippet below:

v-select showing button options in the front end

Initially our Vue, Vuetify code looks like this below, we need to modify it to get our desired results.

So we need to create a function called selectButton that will help us achieve the result we are looking for. Don’t mind the console.log message in this case it is for testing purposes.

Add the event called @change that will help in changing the component dynamically and feed it with the selectButton function that has been created.

Next : Declare selected variable as a string

Feed selected variable to the V-model .

Lastly we need to add the v-if , to render if the directive’s expression returns a truthy value.

In our front end, when a Red Button Options is selected it should show the Red Button components like below

When a Green Button Options is selected it should show the Green Button components like below

This is how you change the components dynamically using Vuetify v-select component Vue and Typescript. Hopefully you find the code helpful . Happy coding.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Salifyanji Taala
Salifyanji Taala

Written by Salifyanji Taala

Philomath. Everything posted is based on my Experience and learning from others.

Responses (2)

Write a response

Hey Sbarnes, thank you for your response. In this tutorial variables and methods are declared in the script part of the code. Since you are new to vuetify. Follow this link https://github.com/SalifyaTaala/Vuetifyproject
The above link is a simple…

Thanks for the tutorial, it's almost exactly what I was looking for, but in some places it is not clear, maybe posting the whole actual code would help.
I'm new to vuetify so these things aren't obvious.
e.g. create the selectButton function, where…