I'm using the Vuetify v-select component : https://vuetifyjs.com/en/components/selects/
I want to make select with image like this :

But i didn't found anything in the documentation
You have to use the item slot https://vuetifyjs.com/en/components/selects/#api
<v-select :items="items" label="Standard">
<template v-slot:selection="{ item, index }">
<img :src="item.image">{{ item.name }}
</template>
<template v-slot:item="{ item }">
<img :src="item.image">{{ item.name }}
</template>
</v-select>
JS:
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
items: [
{ name: 'Foo', image: 'https://www.gravatar.com/avatar/b17065ea1655f1e3283aac8d8fc16019?s=48&d=identicon&r=PG'},
{ name: 'Bar', image: 'https://www.gravatar.com/avatar/b17065ea1655f1e3283aac8d8fc16019?s=48&d=identicon&r=PG'},
{ name: 'Hoo', image: 'https://www.gravatar.com/avatar/b17065ea1655f1e3283aac8d8fc16019?s=48&d=identicon&r=PG'},
{ name: 'Coo', image: 'https://www.gravatar.com/avatar/b17065ea1655f1e3283aac8d8fc16019?s=48&d=identicon&r=PG'}],
}),
})
JSFiddle: https://codepen.io/reijnemans/pen/vYNadMo?editors=1010
You can utilize the slots to fill image content onto select. I have used https://emoji-css.afeld.me/ to get the flags of countries.
Please see the sample Codepen: https://codepen.io/aaha/pen/ZEbRwpy?editors=1011 I couldn't fill the entire list of countries. It will be great if you can fill it and share, I could also use it somewhere. :D
<v-select
v-model="select"
:items="countries"
label="Select"
item-text="name"
>
<template v-slot:item="slotProps">
<i :class="['mr-2', 'em', slotProps.item.flag]"></i>
{{slotProps.item.name}}
</template>
</v-select>
data: {
select: null,
countries: [
{
name: "Andorra",
flag: "em-flag-ad"
},
{
name: "Arab Emirates",
flag: "em-flag-ae"
},
{
name: "Afghanistan",
flag: "em-flag-af"
},
{
name: "Antigua & Barbuda",
flag: "em-flag-ag"
},
{
name: "Albania",
flag: "em-flag-al"
},
{
name: "Anguilla",
flag: "em-flag-ai"
}
],
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With