Skip to content

Instantly share code, notes, and snippets.

@dioncodes
Created June 23, 2022 13:20
Show Gist options
  • Save dioncodes/7bbaa9e8dc667945809dc17a311ad9cf to your computer and use it in GitHub Desktop.
Save dioncodes/7bbaa9e8dc667945809dc17a311ad9cf to your computer and use it in GitHub Desktop.
Vue Inline SVG Wrapper
<template>
<inline-svg
:src="require(`@/assets/svg/${name}.svg`)"
:width="width || size || null"
:height="height || size || null"
:style="{ fill: color || undefined, stroke: strokeColor || undefined }"
/>
</template>
<script lang="ts">
import Vue from 'vue'
import InlineSvg from 'vue-inline-svg'
export default Vue.extend({
name: 'SvgIcon',
components: {
InlineSvg,
},
props: {
name: {
type: String,
required: true,
},
width: {
type: Number,
default: null,
},
height: {
type: Number,
default: null,
},
size: {
type: Number,
default: null,
},
color: {
type: String,
default: undefined,
},
strokeColor: {
type: String,
default: undefined,
},
},
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment