Home  >  Q&A  >  body text

Vuetify 3: Using Svg for v icon

<p>I want to use my custom svg as v icon but I didn't find any solution in the Vuetify v3 documentation. </p> <p>In vuetify v2 I can do something like this in vuetify.js: </p> <pre class="brush:php;toolbar:false;">export default new Vuetify({ icons:{ values: { test: { component: Test, },</pre> <p>I can use it like this:</p> <pre class="brush:php;toolbar:false;"><v-icon size="40">$vuetify.icons.test</v-icon></pre> <p>How do I do the same thing in Vuetify v3? Thanks for your help :)</p>
P粉440453689P粉440453689417 days ago536

reply all(1)I'll reply

  • P粉676821490

    P粉6768214902023-08-29 17:10:57

    The code below shows an example of adding a custom icon to Vuetify along with the mdi icon set and using both icons in a component via aliases.

    vuetify.js

    import { createVuetify } from 'vuetify'
    
    import { aliases, mdi } from 'vuetify/iconsets/mdi-svg'
    
    import folder from '@/customIcons/folderIcon.vue'
    const aliasesCustom = {
      ...aliases,
      folder,
    }
    
    export const vuetify = createVuetify({
      icons: {
          defaultSet: 'mdi',
          aliases: {
            ...aliasesCustom
          },
          sets: {
            mdi,
          },
        },
    })
    

    folderIcon.vue (your custom icon)

    <template>
     <svg>...</svg>
    </template>
    

    Any Securities Regulatory Commission

    <template>
      <v-icon>$folder</v-icon>
      <v-icon>$mdiGithub</v-icon>
    </template>
    

    Original source: Thread in Vuetify Discord channel

    reply
    0
  • Cancelreply