# react-i **Repository Path**: mirrors_leecade/react-i ## Basic Information - **Project Name**: react-i - **Description**: A tiny (1 KB) Component for React(-like). - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2026-02-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # react-i [![npm version](http://img.shields.io/npm/v/react-i.svg?style=flat-square)](https://npmjs.org/package/react-i "View this project on npm") [![npm version](http://img.shields.io/npm/dm/react-i.svg?style=flat-square)](https://npmjs.org/package/react-i "View this project on npm") [![Issue Stats](http://issuestats.com/github/leecade/react-i/badge/pr?style=flat-square)](https://github.com/leecade/react-i/pulls?q=is%3Apr+is%3Aclosed) [![Issue Stats](http://issuestats.com/github/leecade/react-i/badge/issue?style=flat-square)](https://github.com/leecade/react-i/issues?q=is%3Aissue+is%3Aclosed) [![Circle CI](https://circleci.com/gh/leecade/react-i.svg)](https://circleci.com/gh/leecade/react-i) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) A tiny (1 KB gzipped) `` Component for React(-like). > SVG is the best way for cross platform scalable vector graphics, also we can use `react-i` in react-native or react-android project. [DEMO](https://view.gitlab.pro/react/react-i) ![image](https://gitlab.pro/react/react-i/uploads/6ea1589a3fbbe2d5942b9813f59b10f0/image.png) ### Compatibility - IE8+ - React 0.14+ ### Usage ```sh npm i react-i --save ``` ```jsx import I from 'react-i' icon icon ``` #### Props ```jsx static propTypes = { icon: PropTypes.oneOfType([ PropTypes.func, PropTypes.string ]).isRequired, size: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]), style: PropTypes.object, // Use `fill` and `stroke` is a convenient way, auto merge to `style` fill: PropTypes.string, stroke: PropTypes.string, dir: PropTypes.oneOf([ 'left', 'right' ]) } ``` #### How to create a icon Consider for reduce size in the real world, there provides a simple way to create your iconset. - First of all, open the `tools/simple.sketch` file in Sketch ![image](https://gitlab.pro/haoyayi/clinic-profile/uploads/63cff495b500a109bce9e0ba2efaa749/image.png) This is a template file, you may draw your vector icon by yourself, then export as `svg` type (If you want complete the step in AI or PS, notice that keep the canvas size 24x24) - Open the svg file in editor, we will get the code like: ```xml 24x24 Created with Sketch. ``` Don't case the redundant code, we have a tool (in `./tools` folder) to convert it. run `./svg-icon origin.svg`, output: **UPDATE** > There is a standone tool see: https://github.com/leecade/react-i-cli ```sh $ npm i react-i-cli -g $ react-i origin.svg ``` ```js export const Origin = () => ``` Great, we hava a component named `Origin`. - Use it in project Convert all svg file to a js file. ```sh ./svg-icon *.svg >> icons.js ``` Then, we can use it with `react-i`. ``` import React, { Component } from 'react' import ReactDOM, { render } from 'react-dom' import I from 'react-i' import { Origin } from './icons' const App = () =>
render( , document.getElementById('root') ) ``` A effective easy and cheap way to organizing and use your icons, right? #### More Case ```jsx
icon-left
icon-right
Inherit Color
Custom Color
Custom Icon
Support Shadow
big icon
very big icon
small icon
``` Animation Svg example: > Notice that, React(v0.14.x) not support `animateTransform` yet, there is a temporary solution with `dangerouslySetInnerHTML` ```jsx const Spinner = () => ' }}> ``` Try your self: ```sh git clone https://github.com/leecade/react-i.git npm i // edit demo/index.js npm run dev // open demo/index.html ``` ## Need more open-source iconset - [material-design-icons](https://elements.polymer-project.org/elements/iron-icons?view=demo:demo/index.html&active=iron-icons) - [Twig](https://github.com/leecade/twig/tree/master/svg/24) - [polyicon](https://github.com/PolymerLabs/polyicon) ## Refs - [Tips for Creating and Exporting Better SVGs for the Web](http://sarasoueidan.com/blog/svg-tips-for-designers) - [SVG `symbol` a Good Choice for Icons](https://css-tricks.com/svg-symbol-good-choice-icons/) - [An Overview of SVG Sprite Creation Techniques](https://24ways.org/2014/an-overview-of-svg-sprite-creation-techniques/) - [Optimising SVGs for Web Use](https://medium.com/larsenwork-andreas-larsen/optimising-svgs-for-web-use-part-1-67e8f2d4035)