Code Monkey home page Code Monkey logo

create-react-icon's Introduction

create-react-icon

NPM version build status Downloads js-standard-style

Convert one or multiple svg files into inline-svg React component, inspired by react-icons project.

If you are wondering what the benefit is to use inline svg in React component, please check this post Creating an SVG Icon System with React.

Installation

$ npm install create-react-icon -g

Usage

$ create-react-icon ./alert.svg dist
$ create-react-icon ./*.svg dist

Result

Your source svg file:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M200.4 54.1c-1.9-18.7 8.4-32.9 25.8-32.9h63.1c17.4 0 27.7 14.2 25.8 32.9l-27.7 242.2c-1.9 17.4-13.5 28.3-29.6 28.3s-27.7-11-29.6-28.3L200.4 54.1zm57.3 313.1c32.2 0 56 23.8 56 54.8v1.3c0 30.9-23.8 54.8-56 54.8s-56-23.8-56-54.8V422c0-31 23.8-54.8 56-54.8z"/></svg>

Becomes to :

import React from 'react'
import Icon from 'react-icon-base'

export default (props) => {
  return (
    <Icon viewBox='0 0 512 512' {...props}>
      <title>{props.title || 'alert'}</title>
      <g><path d="M200.4 54.1c-1.9-18.7 8.4-32.9 25.8-32.9h63.1c17.4 0 27.7 14.2 25.8 32.9l-27.7 242.2c-1.9 17.4-13.5 28.3-29.6 28.3s-27.7-11-29.6-28.3L200.4 54.1zm57.3 313.1c32.2 0 56 23.8 56 54.8v1.3c0 30.9-23.8 54.8-56 54.8s-56-23.8-56-54.8V422c0-31 23.8-54.8 56-54.8z"/></g>
    </Icon>
  )
}

How to use icons

import AlertIcon from 'alertIcon'

export default (props) => {
   return (<div>
     <AlertIcon title='alert icon' /> Manage my Collections
  </div>)
}

Roadmap

  • Make the base component configurable

License

MIT

create-react-icon's People

Contributors

dependabot-support avatar fraserxu avatar luke-j avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.