Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!