Created
June 23, 2022 13:20
-
-
Save dioncodes/7bbaa9e8dc667945809dc17a311ad9cf to your computer and use it in GitHub Desktop.
Vue Inline SVG Wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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