How to add custom-logo/image in toolbar using vuetify

20,077

Solution 1

With Vuetify 2 and above version, you can add a logo before your toolbar title like this:

<v-toolbar>
  <!-- Adjust the height to your needs, mine is 40 -->
  <img class="mr-3" :src="require('../assets/your_image.png')" height="40"/>
  <v-toolbar-title>Title</v-toolbar-title>
  <v-spacer></v-spacer>
  <v-toolbar-items>
    <v-btn text>Home</v-btn>
    <v-btn text>About</v-btn>
  </v-toolbar-items>
</v-toolbar>

Also, <v-toolbar-side-icon> is already <v-app-bar-nav-icon>

Solution 2

Try to use :

<v-img :src="require('@/assets/mad_logo.png')" >

Solution 3

Instead of using require the loader won't digest to render your actual page

So i prefered the code and enjoy!

     <v-toolbar-side-icon>
            <v-img class="mr-3" src="@/assets/logo.png" height="30px" width="40px"> 
            </v-img>
     </v-toolbar-side-icon>

Regards,

Kamalesh Sivaraj!

Share:
20,077
abhigyan nayak
Author by

abhigyan nayak

an ambitious learner......excelled in c...have some knowledge of c....... code,code and code..until you find another leap to cross - anonymous

Updated on July 09, 2022

Comments

  • abhigyan nayak
    abhigyan nayak almost 2 years

    I am trying to add image/custom logo in the toolbar using Vuetify. I am using v-toolbar to create the navigation bar.

    The image is not showing up. It shows the error of [Vuetify] Image load failed src: ../assets/mad_logo.png

    I tried using <v-img> But it did not work.

    This is how the navigation bar looks like

    enter image description here

    This is the code:

    VuetifyTest.js

       <v-toolbar
        color="primary"
        >
    
    
    
        <v-toolbar-side-icon>
            <v-img src="../assets/mad_logo.png" />
        </v-toolbar-side-icon>  
        <v-toolbar-title class="black--text">Title</v-toolbar-title>
    
        <v-spacer></v-spacer>
        <v-avatar>
          <img
            src="../assets/static.jpeg"
            alt="John"
          >
        </v-avatar>
    
    
      </v-toolbar>
    
    
    </template>
    
    <script lang="js">
      export default  {
        name: 'profile',
        props: [],
        mounted() {
    
        },
        data() {
          return {
    
          }
        },
        methods: {
    
        },
        computed: {
    
        }
    }
    </script>
    
    <style scoped >
    
    </style>
    

    This is the directory structure:

    enter image description here

    How do I attach the logo on the top left of the navigation bar and load the image correctly.

    Any code changes would work. Thanks!

  • nishkaush
    nishkaush almost 5 years
    You can also try this if the above answer doesn't work- <v-img :src="require('../assets/mad_logo.png')" >
  • Marcelus Trojahn
    Marcelus Trojahn over 4 years
    this is def the right answer for vuetify2 a toolbar image.