SVG to Vue Component
Paste SVG markup and get a ready-to-use Vue 3 single-file component — width and height forwarded as props, attributes inherited via v-bind. Runs entirely in your browser.
What the generated SFC includes
- width and height props — the SVG's declared dimensions become default values for
widthandheightprops so callers can override size without touching the component. - v-bind="$attrs" — passes through any attribute the parent provides (class, style, aria-label, event listeners) to the root SVG element.
- Namespace declarations removed — the
xmlnsattribute is stripped; Vue handles SVG namespacing in templates automatically. - xlink:href modernised — the deprecated XLink namespace is replaced with the standard
hrefattribute. - Attribute names unchanged — unlike React, Vue templates do not require camelCase for SVG attributes, so
stroke-widthstaysstroke-width.
JS vs TS script
JS generates a <script setup> block using the runtime defineProps() macro with default values — compatible with any JavaScript Vue 3 project.
TS generates a <script setup lang="ts"> block using the type-based defineProps<>() macro with withDefaults, giving you full type checking and IDE autocompletion.
Frequently Asked Questions
Does this work with Vue 2?+
The output uses the Vue 3 Composition API — specifically defineProps and withDefaults from <script setup>. Vue 2 does not support script setup or defineProps. For Vue 2, you would need to use the Options API with a props object and a render function or template.
Why does v-bind="$attrs" appear on the root element?+
In Vue 3, when a component has a single root element, non-prop attributes passed by the parent are automatically inherited by the root element. Adding v-bind="$attrs" makes this explicit and keeps the component composable — callers can still pass aria-label, class, or event listeners without modifying the component definition.
How do I change the SVG color dynamically?+
Replace hardcoded fill or stroke values with currentColor in your SVG before converting. Then control the icon color via the CSS color property on the parent element or pass a style prop to the component. This pattern works seamlessly with Tailwind utility classes like text-orange-500.
Is my SVG uploaded to a server?+
No. The conversion runs entirely in your browser using the built-in DOM parser. Your SVG markup never leaves your device.
Should I use TypeScript or JavaScript output?+
Choose TypeScript if your Vue project uses lang="ts" in script blocks — you will get type-checked props with IDE autocompletion. Choose JavaScript if your project does not use TypeScript; the output is otherwise identical in behavior.
Related Tools
How to use
- Paste your SVG markup — the Vue SFC appears instantly.
- Set a component name or leave it as SvgIcon.
- Choose JS for JavaScript projects or TS for TypeScript.
- Copy the result and save it as a .vue file in your project.