Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Last active June 26, 2017 12:35
Show Gist options
  • Save daliborgogic/ebd163bb21200f32c655dd1717e29797 to your computer and use it in GitHub Desktop.
Save daliborgogic/ebd163bb21200f32c655dd1717e29797 to your computer and use it in GitHub Desktop.
SVG sprite Vue.js component
<!-- set pug as language, jade is only for gist sintax highlight -->
<template lang="jade">
- var background = 'path(d="M0 0h24v24H0z" fill="none")'
svg(height="0" width="0" style="position:absolute; margin-left: -100%;")
//- If your shape consist of many small chunks, you’ll need to wrap them all with a g tag and add an ID to that group.
g#check-box-outline
#{background}
path(d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z")
g#check-box
#{background}
path(d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z")
//- The xlink:href attribute is a reference to our shape by its ID:
svg.icon(viewBox="0 0 24 24")
use(xlink:href="#check-box")
</template>
<script>
export default {
name: 'icons'
}
</script>
<style lang="stylus">
.icon
width 24px
height 24px
fill #0099CC
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment