Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrapping v-icon with v-tooltip inside text-field?

Tags:

vuetify.js

I need help with creating a text-field, which has an icon inside with a tooltip attached to the icon. My code:

<v-text-field
                    v-model="url">
                  <span slot="label">Url
                   <v-tooltip bottom>
                      <v-icon
                        slot="activator"
                        color="primary"
                        dark
                      >home</v-icon>
                      <span>Tooltip</span>
                    </v-tooltip>
                   </span>
               </v-text-field>

Any ideas?

Thanks.

like image 210
badigard Avatar asked Jul 02 '18 11:07

badigard


People also ask

How do you make a tooltip in Vue?

To create a tooltip using the component approach, we can simply create a button and put the ID in the target attribute. In the code above, we created a button called b-button and gave it a specific ID, tooltip-target-1 .

What is the V icon?

The v-icon component provides a large set of glyphs to provide context to various aspects of your application. For a list of all available icons, visit the official Material Design Icons page. To use any of these icons simply use the mdi- prefix followed by the icon name.


3 Answers

Since v1.1 we can use append (and prepend) slots for this:

<v-text-field v-model="url" label="URL">
    <v-tooltip slot="append" bottom>
        <v-icon slot="activator" color="primary" dark>home</v-icon>
        <span>Tooltip</span>
    </v-tooltip>
</v-text-field>

Codepen

like image 102
Traxo Avatar answered Sep 21 '22 20:09

Traxo


In vuetify version 2.0.7 I am using below code. It works perfectly.

      <v-tooltip bottom>
        <template #activator="{ on }">
          <v-icon color="red" class="mr-1" v-on="on">fab fa-youtube</v-icon>
        </template>
        <span>Tooltip</span>
      </v-tooltip>
like image 31
Adarsh Madrecha Avatar answered Sep 22 '22 20:09

Adarsh Madrecha


displaying tooltip when hovering over the icon inside v-text-field

<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet">
<div id="app">
  <v-app>
    <v-content>
      <v-container>
        <v-text-field v-model="url" label="URL">
          <v-tooltip slot="append">
            <template v-slot:activator="{ on }">
                <v-icon v-on="on" color="primary" dark>
                  mdi-home
                </v-icon>
              </template>
            <span>Tooltip</span>
          </v-tooltip>
        </v-text-field>
      </v-container>
    </v-content>
  </v-app>
</div>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.js"></script>
<script>
  new Vue({
    el: '#app',
    vuetify: new Vuetify(),
    data: {
      url: 'https://stackoverflow.com/'
    }
  })
</script>
like image 21
Ozeranskiy S. Avatar answered Sep 22 '22 20:09

Ozeranskiy S.