A util library for create svg sprites and using them in a react component
Last updated a year ago by chilly101 .
ISC · Repository · Original npm · Tarball · package.json
$ cnpm install svg-icon-react 
SYNC missed versions from official npm registry.

what are we doing here?

The package takes a folder of SVGs, and will create a sprite.svg and svgEnum.js file - which contains names and dimensions for each svg.

The dimensions are scraped from the viewbox, and can help provide a consistant way of displaying svgs. No more worrying about whitespace, menu icon sizes or icon heights in text...

This package also provides a react component, ready to take sprite and enum file!

Beckon thou gods of install

// cli

yarn add react-icon

// you've probably done that while skim reading to be fair

Run the track

// package.json

"scripts": {
  "svgsprite": "extract-svg-data ./path-to-assets ./output-folder",

cool, I should probably think of more words for here really. Phil Collins is definitely {under|over} rated. Weather has been nice laterly...

execute icon sexiness

import ReactIcon from 'react-icons';
import sprite from 'whereever/you/put/it/sprite.svg'
import svgEnum from 'whereever/you/put/it/iconEnum.js'

const YourIconComponent = (
  { iconName, width, height, direction, scale, unitType }
) => (
    // These are the data ones
    // and these are the actual display props

// and you can then use it like so:

<YourIconComponent iconName={svgEnum.GENESIS} width={30} unitType={'px'}>


If you pass only width or height you svg will scale the undefined value based on its viewbox. If you pass both values the icon will always stay constrained but its DOM element will take up the correct space - it'll just fill it best it can.

Current Tags

  • 1.2.1                                ...           latest (a year ago)

3 Versions

  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
Maintainers (1)
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 4
Dev Dependencies (9)
Dependents (0)

Copyright 2014 - 2016 © |