All Projects → stowball → React Native Svg Icon

stowball / React Native Svg Icon

Licence: mit
A simple, but flexible SVG icon component for React Native

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Native Svg Icon

Angular Svg Icon
Angular component for inlining SVGs allowing them to be easily styled with CSS.
Stars: ✭ 151 (-7.93%)
Mutual labels:  svg, svg-icons
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 (+6520.73%)
Mutual labels:  svg, svg-icons
Phosphor React
A flexible icon family for React
Stars: ✭ 97 (-40.85%)
Mutual labels:  svg, svg-icons
Svg Autocrop
🚗🌽🔳An NPM module to autocrop and slim down SVGs
Stars: ✭ 80 (-51.22%)
Mutual labels:  svg, svg-icons
Circle Flags
A collection of 300+ minimal circular SVG country flags
Stars: ✭ 139 (-15.24%)
Mutual labels:  svg, svg-icons
Svg Native Viewer
SVG Native viewer is a library that parses and renders SVG Native documents
Stars: ✭ 85 (-48.17%)
Mutual labels:  svg, svg-icons
Svg Icon
👻 A lightweight library that makes it easier to use SVG icons in your Angular Application
Stars: ✭ 112 (-31.71%)
Mutual labels:  svg, svg-icons
Boxicons
High Quality web friendly icons
Stars: ✭ 1,104 (+573.17%)
Mutual labels:  svg, svg-icons
Svg To Ts
Build performant SVG icon libraries by converting raw SVG files to TypeScript that is optimized for modern tree shaking mechanisms.
Stars: ✭ 131 (-20.12%)
Mutual labels:  svg, svg-icons
Svgiconimagelist
Three engines to render SVG (GDI+, Direct2D or Cairo) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...): TSVGIconImage, TSVGIconImageCollection, TSVGIconVirtualImageList and TSVGIconImageList (for VCL and FMX).
Stars: ✭ 127 (-22.56%)
Mutual labels:  svg, svg-icons
Svgsprit.es
Public endpoint to generate SVG Sprites
Stars: ✭ 73 (-55.49%)
Mutual labels:  svg, svg-icons
Vivid
a JavaScript library which is built to easily customize and use the SVG Icons with a blaze.
Stars: ✭ 1,797 (+995.73%)
Mutual labels:  svg, svg-icons
Svgeez
A Ruby gem for automatically generating an SVG sprite from a folder of SVG icons.
Stars: ✭ 69 (-57.93%)
Mutual labels:  svg, svg-icons
React Cassette Player
Simple ReactJS HTML5 audio player component built with SVG icons from The Noun Project.
Stars: ✭ 93 (-43.29%)
Mutual labels:  svg, svg-icons
Phosphor Icons
A flexible icon family for the web
Stars: ✭ 56 (-65.85%)
Mutual labels:  svg, svg-icons
Icons
The premium icon font for @uiwjs Component Library. https://uiwjs.github.io/icons
Stars: ✭ 99 (-39.63%)
Mutual labels:  svg, svg-icons
React Icomoon
It allows you to simply view the icons in the selection.json file provided by Icomoon.
Stars: ✭ 48 (-70.73%)
Mutual labels:  svg, svg-icons
Vmware Stencils
Official VMware Stencils
Stars: ✭ 57 (-65.24%)
Mutual labels:  svg, svg-icons
Simple Icons
SVG icons for popular brands
Stars: ✭ 12,090 (+7271.95%)
Mutual labels:  svg, svg-icons
Coreui Icons
CoreUI Free Icons - Premium designed free icon set with marks in SVG, Webfont and raster formats
Stars: ✭ 1,813 (+1005.49%)
Mutual labels:  svg, svg-icons

react-native-svg-icon

A simple, but flexible SVG icon component for React Native. Read the introductory blog post.

npm version Build Status

Installation

  1. Ensure sure you've installed react-native-svg
  2. npm i react-native-svg-icon --save

NOTICE

Setup

  1. Create an object of your SVG icons

    import React from 'react';
    import { G, Path } from 'react-native-svg';
    
    // Each nameValuePair can be:
    // * Name: <Svg />; or
    // * Name: { svg: <Svg />, viewBox: '0 0 50 50' }
    
    export default {
        SortArrows: <G><Path d="M0 45h90L45 0 0 45z"/><Path d="M0 55h90l-45 45L0 55z"/></G>,
        Tick: {
            svg: <Path d="M38.729 75.688a4.48 4.48 0 0 1-3.21-1.356L16.558 55.004c-1.774-1.807-1.774-4.736-.001-6.543a4.48 4.48 0 0 1 6.42 0l15.753 16.056 37.749-38.474a4.478 4.478 0 0 1 6.419 0c1.773 1.806 1.773 4.736 0 6.543L41.939 74.332a4.48 4.48 0 0 1-3.21 1.356z"/>,
            viewBox: '0 0 50 50',
        },
    }
    

    To conform to React/JSX standards, we need to convert SVG elements to begin with a capital letter, and convert hyphenated attributes to camelCase. For example. <path> becomes <Path> and stop-color becomes stopColor.

  2. Create an <Icon /> component as a bridge between react-native-svg-icon's <SvgIcon /> which imports the above SVGs

    import React from 'react';
    import SvgIcon from 'react-native-svg-icon';
    import svgs from './assets/svgs';
    
    const Icon = (props) => <SvgIcon {...props} svgs={svgs} />;
    
    export default Icon;
    

Usage

Use your <Icon /> in your views.

import Icon from './components/Icon';

// Inside some view component
render() {
    return (
        <Fragment>
          <Icon name="SortArrows" height="20" width="20" />
          <Icon name="Tick" fill="#0f0" viewBox="0 0 200 200" />
          <Icon name="Star" fill="transparent" stroke="#fff" strokeWidth="5" />
        </Fragment>
    );
}

Pro Tip: An SVG name suffixed with '.ios' or '.android' will automatically be rendered on the appropriate platform when passing the base name as the name prop.

Props

Default

{
    fill: '#000',
    fillRule: 'evenodd',
    height: '44',
    width: '44',
    viewBox: '0 0 100 100',
}

These can be overridden in your <Icon />'s defaultProps or an a per instance basis.

Types

{
    defaultViewBox: string,
    fill: string.isRequired,
    fillRule: string,
    height: oneOfType([number, string]).isRequired,
    name: string.isRequired,
    stroke: string,
    strokeWidth: oneOfType([number, string]),
    style: oneOfType([array, object]),
    svgs: object.isRequired,
    width: oneOfType([number, string]).isRequired,
    viewBox: string,
}

The specificity order for viewBox is:

  1. <Icon viewBox />
  2. { Name: { viewBox: '' } }
  3. Icon.defaultProps.defaultViewBox
  4. SvgIcon.defaultProps.viewBox

Copyright (c) 2018 Matt Stow
Licensed under the MIT license (see LICENSE for details)

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