Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
Vue unicons - set viewBox in custom icon

I have just installed the Vue Unicons module in my vue project.

Vue version: 2.6.10
Vue unicons version: 3.3.1

I am trying to create my own custom icons as explained here:

custom-icons.js:

export const myTestIcon = {
    name: 'myTestIcon',
    style: 'line',
    viewBox: '0 0 680 680',
    path: '<path d="M 635 497 l 1 -466 l -620 0 L 20 640 L 516 643 L 231 221z"></path>';
}

app.js:

import Unicon from 'vue-unicons/dist/vue-unicons-vue2.umd';
import { myTestIcon } from './custom-icons';
Unicon.add([myTestIcon]);

App.vue:

<unicon name="my-test-icon"></unicon>

Although I set viewBox is the icon definition, the icon is rendered with default value of viewBox (0 0 24 24).

If I add viewBox="0 0 650 650" or even v-bind="{viewBox:'0 0 650 650'}" to the <unicon> element, it works fine. But I cannot do it since I use icons dynamically.

I read in this place that it might happen due to compilation, but the answer did not help me.

Any idea how can I achieve it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The custom icon definition schema does not include a viewBox property, so setting it in your definition has no effect. Specifically, Vue Unicons only reads name, style, and path from the custom icon definition.

The viewBox can only be set as a prop on the <unicon> component:

<unicon name="my-custom-icon"
        viewBox="0 0 32 32" 👈
        width="64"
        height="64" />

demo

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda