All Projects → blueberryapps → react-svg-icon-generator

blueberryapps / react-svg-icon-generator

Licence: MIT license
Generate React Icon Component from SVG icons to show, resize and recolor them.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-svg-icon-generator

Icons Flat Osx
Free Flat icons For OSX
Stars: ✭ 366 (+463.08%)
Mutual labels:  svg-icons, icon
Svgtofont
Read a set of SVG icons and ouput a TTF/EOT/WOFF/WOFF2/SVG font.
Stars: ✭ 149 (+129.23%)
Mutual labels:  svg-icons, icon
React Icomoon
It allows you to simply view the icons in the selection.json file provided by Icomoon.
Stars: ✭ 48 (-26.15%)
Mutual labels:  svg-icons, icon
icons-flat-osx
Free Flat icons For OSX
Stars: ✭ 371 (+470.77%)
Mutual labels:  svg-icons, icon
react-crud-icons
57 SVG icons for CRUD applications, packaged as a React component with light & dark themes and tooltip.
Stars: ✭ 19 (-70.77%)
Mutual labels:  react-component, svg-icons
vue-iconfont
更优雅地使用 Iconfont.cn,同时支持 font-class 引入和 symbol 引入。
Stars: ✭ 27 (-58.46%)
Mutual labels:  svg-icons, icon
Tabler Icons
A set of over 1400 free MIT-licensed high-quality SVG icons for you to use in your web projects.
Stars: ✭ 10,858 (+16604.62%)
Mutual labels:  svg-icons, icon
Icons
The premium icon font for @uiwjs Component Library. https://uiwjs.github.io/icons
Stars: ✭ 99 (+52.31%)
Mutual labels:  svg-icons, icon
react-ratings-declarative
A customizable rating component for selecting x widgets or visualizing x widgets
Stars: ✭ 41 (-36.92%)
Mutual labels:  react-component, svg-icons
Akar Icons
A perfectly rounded icon library made for designers, developers, and pretty much everyone.
Stars: ✭ 184 (+183.08%)
Mutual labels:  svg-icons, icon
archer-svgs
异步加载svg解决方案
Stars: ✭ 23 (-64.62%)
Mutual labels:  svg-icons, icon
React Cassette Player
Simple ReactJS HTML5 audio player component built with SVG icons from The Noun Project.
Stars: ✭ 93 (+43.08%)
Mutual labels:  react-component, svg-icons
svg-gobbler
Open source browser extension that makes designing and developing easier by finding, processing, exporting, optimizing, and managing SVG content.
Stars: ✭ 272 (+318.46%)
Mutual labels:  svg-icons, icon
geticon
Web / IT project stack / tool / technique icon / logo collection & markdown / HTML generator 🚀
Stars: ✭ 101 (+55.38%)
Mutual labels:  svg-icons, icon
Cryptocurrency Icons
A set of icons for all the main cryptocurrencies and altcoins, in a range of styles and sizes.
Stars: ✭ 2,116 (+3155.38%)
Mutual labels:  svg-icons, icon
react-star-ratings
A customizable svg star rating component for selecting x stars or visualizing x stars
Stars: ✭ 128 (+96.92%)
Mutual labels:  react-component, svg-icons
React Kawaii
Cute SVG React Components
Stars: ✭ 2,709 (+4067.69%)
Mutual labels:  react-component, svg-icons
Sweetalert React
Declarative SweetAlert in React
Stars: ✭ 244 (+275.38%)
Mutual labels:  react-component
react-bolivianite-grid
React grid component for virtualized rendering large tabular data.
Stars: ✭ 95 (+46.15%)
Mutual labels:  react-component
Boundless
✨ accessible, battle-tested React components with infinite composability
Stars: ✭ 242 (+272.31%)
Mutual labels:  react-component

React SVG Icon Generator Dependency Status

Generate React Icon Component from SVG icons to show, resize and recolor them.

We have prepared live demo for you at React SVG Icon Live Generator

📱Supports React Native 💕

Fastest way to get your svg converted to React Component

yarn global add react-svg-icon-generator
yarn svg-icon-generate -- --svgDir ./icons --destination ./Icon.tsx

for detailed options run just yarn react-svg-icon-generator

Preview of Generated Component

Preview

source directory with SVG and this is output component from gulp task so in production you are without any dependencies at all.

Instalation

you need to add this just to development, because it will generate self contained react component directly to your codebase

npm install --save-dev react-svg-icon-generator

Setup gulp task simple

const configureSvgIcon = require('react-svg-icon-generator').default;

configureSvgIcon({
  destination: path.join(__dirname, 'components', 'Icon.js'),
  svgDir: './icons',
});
  • svgDir (required) - path to your directory with svg files. Can be relative path but it is better to use path.join(__dirname, 'icons') absolute path so it will work in any directory of project
  • destination (required) - path.join(__dirname, 'components', 'Icon.js')

run it by gulp svg-icon

Setup gulp task full

const configureSvgIcon = require('react-svg-icon-generator').default;

configureSvgIcon({
  comment: 'Generated by gulp svg-icon, if you add new icon run gulp svg-icon',
  componentName: 'Icon',
  destination: path.join(__dirname, 'components', 'Icon.js'),
  keepFillColor: false,
  native: false,
  radium: true,
  reactPureRender: true,
  svgDir: path.join(__dirname, 'icons'),
  template: path.join(__dirname, 'template', 'icon.nunjucks'),
});
  • comment (optional) - it will be added to generated component, so other developer will know what to do
  • componentName (optional) - it will change the name of the component, default to 'Icon'
  • keepFillColor (optional) - it will keep the original fill color from imported SVG in case you want to use multiple colors in your icon, therefore you will not be able to use color prop
  • native (optional) - it will generate component that can be used in React Native projects. This functionality depends on react-native-svg library that has to be installed separately (it is not included in dependencies). You can easily overwrite default native template using template option
  • reactPureRender (optional) - it will use import {PureComponent} from 'react'; instead of import {Component} from 'react';. If you use this, make sure you use React >= v15.3.0.
  • radium (optional) - it will import radium and wrap Icon component with Radium wrapper. In order to use Radium it has to be installed separately (it is not part of dependencies).
  • template (optional) - provide path to your custom template, you can look at example at Icon.template

run it by gulp svg-icon

Setup gulp task own name

const {configureGenerator} = require('react-svg-icon-generator').default;

const config = {
  comment: 'Generated by gulp svg-icon, if you add new icon run gulp svg-icon-whatever',
  destination: path.join(__dirname, 'components', 'Icon.js'),
  reactPureRender: true,
  svgDir: path.join(__dirname, 'icons'),
  template: path.join(__dirname, 'template', 'icon.nunjucks'),
}

gulp.task('svg-icon-whatever', configureGenerator(config));

same as previous + your own task name

Use generate Icon component

import React, {Component} from 'react';
import Icon from './Icon';

export default class App extends Component {
  render() {
    return (
      <div>
        Simple possible usage
        <Icon kind='clock' />

        Setup color and bounding width and height
        <Icon kind='close' color='#748' width={500} height={100} />

        Setup color and bounding width and height to size (square)
        <Icon kind='close' color='red' size={600} />

        Setup custom style and className
        <Icon kind="arrow_left" style={{transform: 'scaleX(-1)'}} className="custom-class" />

        Setup onClick behavior
        <Icon kind='close' onClick={() => alert('clicked on icon')} />

        Show all icons at once with description (for finding right icon)
        <Icon preview />
      </div>
    );
  }
}

any prop which is not listed will be passed directly to svg as rest props.

Development

git clone [email protected]:blueberryapps/react-svg-icon-generator.git
cd react-svg-icon
npm i
npm link
cd examples/simple
npm link react-svg-icon-generator
npm i
gulp svg-icon
npm start
open http://127.0.0.1:3000

Thanks

This package was build upon Library Boilerplate from Dan Abramov

Made with love by

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].