Vuetify 3: Using Svg for v icon
P粉440453689
P粉440453689 2023-08-28 21:34:41
0
1
667
<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粉440453689
P粉440453689

reply all(1)
P粉676821490

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template