All Projects → franzheidl → sass-inline-svg

franzheidl / sass-inline-svg

Licence: MIT license
Inline url-encoded SVG with Sass. Optional variable string replacement included!

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to sass-inline-svg

svg-gobbler
Open source browser extension that makes designing and developing easier by finding, processing, exporting, optimizing, and managing SVG content.
Stars: ✭ 272 (+1195.24%)
Mutual labels:  svg-icons, inline-svg
react-crud-icons
57 SVG icons for CRUD applications, packaged as a React component with light & dark themes and tooltip.
Stars: ✭ 19 (-9.52%)
Mutual labels:  svg-icons, inline-svg
md-svg-vue
Material design icons by Google for Vue.js & Nuxt.js (server side support & inline svg with path)
Stars: ✭ 14 (-33.33%)
Mutual labels:  svg-icons, inline-svg
Bytesize Icons
Tiny style-controlled SVG iconset (101 icons, 12kb)
Stars: ✭ 3,662 (+17338.1%)
Mutual labels:  svg-icons, inline-svg
Weather Underground Icons
Weather Underground Icons ( PNG & SVG )
Stars: ✭ 186 (+785.71%)
Mutual labels:  svg-icons
Webfonts Loader
Make an icon font from SVGs!
Stars: ✭ 153 (+628.57%)
Mutual labels:  svg-icons
Angular Svg Icon
Angular component for inlining SVGs allowing them to be easily styled with CSS.
Stars: ✭ 151 (+619.05%)
Mutual labels:  svg-icons
Vivid
a JavaScript library which is built to easily customize and use the SVG Icons with a blaze.
Stars: ✭ 1,797 (+8457.14%)
Mutual labels:  svg-icons
Font Awesome
The iconic SVG, font, and CSS toolkit
Stars: ✭ 66,937 (+318647.62%)
Mutual labels:  svg-icons
React Kawaii
Cute SVG React Components
Stars: ✭ 2,709 (+12800%)
Mutual labels:  svg-icons
Feathericon
simply generic vector icon collection - including sketch file, svg files, and font files.
Stars: ✭ 178 (+747.62%)
Mutual labels:  svg-icons
Fontawesome
Easily insert FontAwesome icons into R Markdown docs and Shiny apps
Stars: ✭ 160 (+661.9%)
Mutual labels:  svg-icons
Supertinyicons
Under 1KB each! Super Tiny Icons are miniscule SVG versions of your favourite website and app logos
Stars: ✭ 13,177 (+62647.62%)
Mutual labels:  svg-icons
Cryptocurrency Icons
A set of icons for all the main cryptocurrencies and altcoins, in a range of styles and sizes.
Stars: ✭ 2,116 (+9976.19%)
Mutual labels:  svg-icons
Svg Credit Card Payment Icons
SVG Credit Card & Payment Icons: 6 Styles, 80 Icons
Stars: ✭ 227 (+980.95%)
Mutual labels:  svg-icons
Svgtofont
Read a set of SVG icons and ouput a TTF/EOT/WOFF/WOFF2/SVG font.
Stars: ✭ 149 (+609.52%)
Mutual labels:  svg-icons
File Icon Vectors
A collection of file type icons in SVG format
Stars: ✭ 171 (+714.29%)
Mutual labels:  svg-icons
Small N Flat
svg icons on a 24px grid
Stars: ✭ 205 (+876.19%)
Mutual labels:  svg-icons
Webfont
Awesome generator of webfont
Stars: ✭ 170 (+709.52%)
Mutual labels:  svg-icons
Materialdesign Svg
@mdi/svg Dist for Material Design Icons.
Stars: ✭ 166 (+690.48%)
Mutual labels:  svg-icons

Sass-Inline-Svg

Gem Version

Inline url-encoded SVG with Sass. Optional variable string replacement included!

This is a Ruby Gem to be used with Ruby Sass, a version of this for node/npm-based environments with node-sass lives here: sass-inline-svg-utf8

Installation

gem install sass_inline_svg

Add this line to your application's Gemfile:

gem 'sass_inline_svg'

Usage

Sass-inline-svg adds a inline_svg function you can use with Sass. It url-encodes the contents of the specified file and inlines it in your CSS (Url-encoded SVG is about 30% smaller than base64).

###Basic

.my-thing {
    background-image: inline_svg('my-file.svg');
}

When working with plain Sass, you'll have to use the full path to the svg file, when using Rails the path will be resolved by the Rails asset pipeline.

###Replacing Variable Strings

Replacing variable strings in SVG when inlining them with Sass makes sense e.g. if you need multiple variants of the same graphic with different fill colors.

With Sass-Inline-Svg you only need one source svg file with a variable string for fill:

…
<polygon fill="fillcolor" points="[…] "/>
…

The variants needed can be created during inlinig with Sass. Pass a Sass map of replacements as a second parameter:

.my-thing {
    background-image: inline_svg('my-file.svg', ( fillcolor: '#fff' ));
}

This will replace all occurences of fillcolor in your SVG with #fff:

…
<polygon fill="#fff" points="[…]"/>
…

Note: If you use $- or @-prefixed variable names in your SVG or if you want to replace an existing hex color, you'll have to quote the keys in your raplement Sass map:

.my-thing {
    background-image: inline_svg('my-file.svg', ( '$fillcolor': '#fff' ));
}

or

.my-thing {
    background-image: inline_svg('my-file.svg', ( '#000': '#fff' ));
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].