I'm working with vuetify 2.x and I want to know how to show a tooltip for each drop-down item of v-autocomplete.
The drop-down has checkbox and textfield
<v-autocomplete
solo
:items="..."
v-model="selected"
clearable
multiple
>
</v-autocomplete>
Problem-
I tried using v-slot:item to write the tooltip for individual items but the checkbox does not get clicked when the text is clicked
So basically the v-autocomplete does not work properly when this is used
Can anyone show me how to solve it so that the checkboxes work and also the tooltip shows?
Tooltips works fine with v-slot:item. By example, this way:
<v-autocomplete
v-model="values"
:items="items"
solo
clearable
multiple>
<template #item="data">
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-layout wrap v-on="on" v-bind="attrs">
<v-list-item-action>
<v-checkbox v-model="data.attrs.inputValue"/>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>{{data.item}}</v-list-item-title>
</v-list-item-content>
</v-layout>
</template>
<span>{{ `${data.item} tooltip` }}</span>
</v-tooltip>
</template>
</v-autocomplete>
...
data: () => ({
items: ['foo', 'bar', 'fizz', 'buzz'],
values: ['foo', 'bar'],
value: null,
}),
You may test this at CodePen.
Related
I have a piece of working code from Veutify 1.5.6 that includes an icon inside of a data table that, when clicked, displays a menu. When clicked the activator shows the list that was activated.
I have a codepen with this example
I want the same functionality, but Vuetify 2 does not have slot="activator".
It looks like they use v-slot:activator="{ on }" with a template tag, but I can't get this replicated over.
This is my attempt at it.
<v-data-table
:headers="labels"
:items="data"
>
<template v-slot:[`item.statusIcon`]="{ item }">
<td style="cursor: pointer;">
<v-icon :class="item.status">{{item.statusIcon}}
<template v-slot:activator="{ on }">
<v-list>
<v-list-item
v-on="on"
v-for="(status, index) in statusItems"
:key="index"
:class="status.title"
#click="setStatus(item, status.title)"
>{{ status.title }}></v-list-item>
</v-list>
</template>
</v-icon>
</td>
</template>
</v-data-table>
There's definitely something small I'm missing and I know that the v-icon should be under the template, but I keep getting this error
'v-slot' directive must be owned by a custom element, but 'td', 'div', 'template' is not
I found this thread, but still no help.
Any help would be appreciated
You should wrap the icon with v-menu component then use this icon as menu activator :
<v-menu offset-y>
<template v-slot:activator="{ on, attrs }">
<v-icon v-on="on" :class="item.status">{{item.statusIcon}}
</v-icon>
</template>
<v-list>
<v-list-item
v-for="(status, index) in statusItems"
:key="index"
:class="status.title"
#click="setStatus(item, status.title)"
>{{ status.title }}></v-list-item>
</v-list>
</v-menu>
I'm pretty new to Vue/Vuetify. I'm working on select option for a site I'm working on, and I want to use an icon as the label as opposed to text. I want to do something like the image below, but I'm not sure if it's even possible. Any guidance would be appreciated.
Thanks!
HTML
<div id="app">
<v-app class="container">
<v-select
v-model="select"
:items="permissions"
label="Select"
item-text="name"
>
<template v-slot:item="slotProps" >
<i :class="['mr-2', 'mdi', slotProps.item.flag]"></i>
{{slotProps.item.name}}
</template>
</v-select>
</v-app>
</div>
VUEJS
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: {
select: null,
permissions: [
{
name: "Global",
flag: "mdi-earth"
},
{
name: "Private",
flag: "mdi-lock"
}
],
}
})
you can use vuetify selection slot for v-select and show the icon of the selected item instead of test.
something like this:
<template>
<v-container fluid>
<v-select
v-model="value"
:items="items"
label="Select Item"
multiple
>
<template #selection="{ item }">
<v-icon> {{ getItemIcon(item) }} </v-icon>
</template>
</v-select>
</v-container>
</template>
and you need to write the getItemIcon method as to return the icon based on the text.
For some reason my side it does not work as I wanted - the icon to be inside the selection text and when selected, to show it. Therefore, I added another template as follows:
<template>
<v-container fluid>
<v-select
v-model="value"
:items="items"
label="Select Item"
>
<template v-slot:item="{ item }">
<v-icon> {{ getItemIcon(item) }} </v-icon>
</template>
<template #selection="{ item }">
<v-icon> {{ getItemIcon(item) }} </v-icon>
</template>
</v-select>
</v-container>
</template>
If someone knows easier way to do so, I will be happy to see it, because, currently I have a repeatable code for the .
I have a v-menu which contains a v-list with a custom component.
<v-toolbar class="transparent">
<v-menu offset-y>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on">
<span><v-icon>mdi-menu</v-icon></span>
</v-btn>
</template>
<v-list>
<AdminAgentList/>
</v-list>
</v-menu>
... more ...
That component is a dialog which defines a v-list-item to slot into the v-list in the v-menu.
<template>
<div> <!-- Agent List -->
<v-dialog v-model="agentList_dlgOpen" persistent max-width="40%" #keydown.esc="agentList_dlgOpen = false">
<template v-slot:activator="{ on, attrs }">
<v-list-item v-bind="attrs" v-on="on">
<v-list-item-title><v-icon>mdi-account-multiple</v-icon> Agent List</v-list-item-title>
</v-list-item>
</template>
<v-card>
<v-card-title>Agent List Maintenance</v-card-title>
<v-card-text>
...
The problem I have is that when I click the dropdown menu item, the dialog appears and works fine. Once I dismiss the dialog, I'm back to the page but the menu item (the "Agent List" dropdown itself) is still showing hovering above the rest of the page. How do I get the dropdown list to disappear after I select something from it?
the problem is if the list item is the activator then it must be open until the dialog is open
my solution would be:
<v-menu offset-y v-model="menu">
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on">
<span><v-icon>mdi-menu</v-icon></span>
</v-btn>
</template>
<v-list>
<AdminAgentList #close-menu="menu = false" />
</v-list>
</v-menu>
adding a v-model to the menu and controlling visibility
and in the other component AdminAgentList:
watch: {
agentList_dlgOpen(val) {
if (!val) {
this.$emit("close-menu");
}
},
},
a watcher to check if the dialog closed
Try this.
<v-toolbar class="transparent">
<v-menu #input="onMenuToggle" open-on-hover v-model="isOpened" offset-y>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on">
<span><v-icon>mdi-menu</v-icon></span>
</v-btn>
</template>
<v-list>
<AdminAgentList/>
</v-list>
</v-menu>
export default {
data() {
return {
isOpened: false,
selectedCategori: [],
categori: {},
overlay: false,
};
},
methods: {
onMenuToggle(val) {
this.isOpened = val;
},
},
};
</script>
I'am using vuetify and i want make auto complete like the one on their official site.
But i'm faces some issues :
The items value not appear in the return list and i don't know how to make appear the links.
Here is my code.
Thanks You
<template>
<v-app>
<v-app-bar app color="primary" dark>
<v-app-bar-nav-icon #click="drawer = true"></v-app-bar-nav-icon>
<v-toolbar-title> Board </v-toolbar-title>
<v-spacer></v-spacer>
<v-autocomplete
:loading="loading"
:filter="v => v"
:items="items"
:search-input.sync="search"
v-model="select"
flat hide-no-data hide-details return-object placeholder="Search ...">
<v-list-tile
slot="prepend-item"
class="grey--text">
{{ items.length }} menus found
</v-list-tile>
<template slot="selection" slot-scope="{ item }">
{{item.name}} {{item.url}}
</template>
<template slot="item" slot-scope="{ item }">
<v-list-tile-content>
<p class='fullName'>{{item.name}} {{item.url}}</p>
</v-list-tile-content>
</template>
</v-autocomplete>
</v-app-bar>
<v-main>
<HelloWorld/>
</v-main>
</v-app>
I went through your issue and try to make a codepen and it worked.
My suggestion is that you should consider data structure when you use object with auto complete and it 's needed even you use v-select.
Please check this pen. https://codepen.io/endmaster0809/pen/qBZRywZ
items: [
{
name: 'Alerts',
url: 'https://vuetifyjs.com/en/components/alerts/'
},
{
name: 'Autocompletes',
url: 'https://vuetifyjs.com/en/components/autocompletes/#autocompletes'
}
],
select: {
name: 'Alerts',
url: 'https://vuetifyjs.com/en/components/alerts/'
},
Two problems that I'm having with Vuetify's combobox:
Input is cleared on blur (combobox not focused on) and I don't want this. This doesn't happen if I don't customize how my items look with v-slot:item though.
Can't select any of the items when I'm trying to customize my items with v-slot:item, but I can select them if I don't customize the items.
I don't know what I'm doing wrong when I basically just copied straight from the documentation and adjusted it to my needs.
<v-combobox
#focus="isShaped = true"
#blur="isShaped = false"
v-model="card_name"
:loading="isLoading"
:items="cards"
hide-no-data
prepend-inner-icon="mdi-magnify"
append-icon=""
outlined rounded :shaped="isShaped"
label="Search for a card"
:search-input.sync="search"
item-text="name"
item-value="set_name"
>
<template v-slot:item="{ item }">
<v-list-item>
<v-list-item-content>
<v-list-item-title class="mb-2">{{item.name}}</v-list-item-title>
<v-list-item-subtitle>{{item.set_name}}</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
</template>
<template v-slot:selection="{ item }">
<span v-text="item.name"></span>
</template>
<template v-slot:progress>
<v-progress-circular
class="mt-3"
v-if="isLoading"
indeterminate
color="primary"
:width="2"
:size="30"
></v-progress-circular>
</template>
</v-combobox>
Here's the codepen: https://codepen.io/chataolauj/pen/RwwYxBg?editors=1010