Skip to content

Instantly share code, notes, and snippets.

@allusis
Created February 15, 2016 18:50
Show Gist options
  • Save allusis/d136e126238fb75e9b13 to your computer and use it in GitHub Desktop.
Save allusis/d136e126238fb75e9b13 to your computer and use it in GitHub Desktop.
SVG Icon Sprites in VisualForce
// Color it with CSS like a boss
.chevron-icon {
width:20px;
height:20px;
fill:$brand-primary;
&:hover {
fill:darken($brand-primary,10%);
}
}
<!-- CSS will cascade the fill or stroke through the shapes, as long as there are no presentational fill attributes on the shapes themselves -->
<apex:component layout="none">
<svg xmlns="http://www.w3.org/2000/svg" class="hide">
<symbol id="chevron" viewBox="0 0 15.5 39.5">
<polygon points="15.5,19.8 10.2,19.8 0,0 5.2,0 "/>
<polygon points="15.5,19.8 10.2,19.8 0,39.5 5.2,39.5 "/>
</symbol>
</svg>
</apex:component>
<!-- Include the component with all of the symbol's -->
<c:IconSprite />
<!-- Reference the ID of the symbol you'd like to use-->
<svg class="chevron-icon">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#chevron"></use>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment