All Projects → sairion → Svg Inline React

sairion / Svg Inline React

Licence: mit
Inline svg wrapper component for React

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Svg Inline React

Svg Icon
👻 A lightweight library that makes it easier to use SVG icons in your Angular Application
Stars: ✭ 112 (-6.67%)
Mutual labels:  svg
X6
🚀 JavaScript diagramming library that uses SVG and HTML for rendering.
Stars: ✭ 2,686 (+2138.33%)
Mutual labels:  svg
Blazor.diagrams
A fully customizable and extensible all-purpose diagrams library for Blazor
Stars: ✭ 119 (-0.83%)
Mutual labels:  svg
Leader Line
Draw a leader line in your web page.
Stars: ✭ 1,872 (+1460%)
Mutual labels:  svg
Elemental2
Type checked access to browser APIs for Java code.
Stars: ✭ 115 (-4.17%)
Mutual labels:  svg
Apexcharts.js
📊 Interactive JavaScript Charts built on SVG
Stars: ✭ 10,991 (+9059.17%)
Mutual labels:  svg
Bgrabitmap
📜 BGRABitmap graphics library made with Lazarus (Free Pascal).
Stars: ✭ 112 (-6.67%)
Mutual labels:  svg
Facesjs
A JavaScript library for generating vector-based cartoon faces
Stars: ✭ 119 (-0.83%)
Mutual labels:  svg
Vue Weather
基于vue.js 2.0的天气应用demo
Stars: ✭ 116 (-3.33%)
Mutual labels:  svg
Geojson2svg
Converts geojson to svg string given svg viewport size and maps extent.
Stars: ✭ 117 (-2.5%)
Mutual labels:  svg
Svgdragtree
一个可以通过拖放 SVG 图标,来生成拥有树状结构的视图与数据的前端组件。 SDT example:
Stars: ✭ 113 (-5.83%)
Mutual labels:  svg
Vue Graph
⚡️ Vue components based on the JUI chart available in Vue.js
Stars: ✭ 114 (-5%)
Mutual labels:  svg
React Native Svg Animations
SVG Animations wrapper for react-native.
Stars: ✭ 117 (-2.5%)
Mutual labels:  svg
React Fast Charts
Blazing Fast Charting Library in React with loading time less than 50ms
Stars: ✭ 113 (-5.83%)
Mutual labels:  svg
Snap.svg.zpd
A zoom/pan/drag/rotate plugin for Snap.svg (useful for view only)
Stars: ✭ 119 (-0.83%)
Mutual labels:  svg
Python Altium
Altium schematic format documentation, SVG converter and TK viewer
Stars: ✭ 112 (-6.67%)
Mutual labels:  svg
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 (+8948.33%)
Mutual labels:  svg
Vue Calendar Heatmap
A lightweight calendar heatmap Vuejs component built on SVG, inspired by github's contribution calendar graph
Stars: ✭ 120 (+0%)
Mutual labels:  svg
Svg Pathdata
Parse SVG PathDatas
Stars: ✭ 119 (-0.83%)
Mutual labels:  svg
Teenyicons
Tiny minimal 1px icons designed to fit in the smallest places.
Stars: ✭ 1,631 (+1259.17%)
Mutual labels:  svg

svg-inline-react: Inline SVG wrapper component for React

This component wraps dangerouslyInnerHTML prop for easier use. Inlining SVG has pros and cons; See "Using SVG" for further detail. However, I recommended to use static svg transformed as React component, since React now supports svg properly.

note for 1.x.x user: transpiling is discontinued

I removed dist and es and made lib (which is ES2015 source) default, and there are several reason for it. For now use of ES2015 (and modules) is widespread, there are many tools supporting it (i.e. Webpack 2, Rollup), and you will use them anyway – if you are using React/etc. If you want to stay in CommonJS land, please specify deps as 1.x.x. i.e) svg-inline-react: 1.x.x

Usage

You can use svg-inline-loader with Webpack to inline SVG.

Example:

import InlineSVG from 'svg-inline-react';

// Use with loader
<InlineSVG src={require("svg-inline-loader!icon.svg")} />

// Use without loader
const svgSource = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid" width="48" height="48" viewBox="0 0 48 48">
  <g id="artboard-1">
    <path d="m-115.8,119.6c-12.8-22-3.2,33.6-3.2,33.6,8.8,34.4,145.6-17.6,145.6-17.6s168.8-30.4,180-34.4,96.8,1.6,96.8,1.6l-4.8-22.4c-64.8-46.4-75.2-16.8-88.8-20.8s-11.2,5.6-14.4,6.4-42.4-24-48.8-23.2-31.62-23.007-16.8,8.8c22.23,47.707-60.759,37.627-75.2,28-16.8-11.2,7.2,18.4,7.2,18.4,18.4,20-16,3.2-16,3.2-34.4-12.8-58.4,12.8-61.6,13.6s-8,4-8.8-2.4-6.865-21.256-40,3.2c-33.6,24.8-44,8.8-44,8.8l-7.2-4.8z" class="cls-1"/>
  </g>
</svg>`;
<InlineSVG src={svgSource} />

prop src : string

valid SVG element string.

prop element : string

You can change element where svg included using element prop, default is <i />. But self closed tags like img is not allowed, and an error will be thrown from React side.

prop raw : bool (experimental!)

This prop allows your svg file to be rendered directly, without a container element wraps it. This is an experimental feature. Also, the prop will be ignored on server side rendering environment.

Notes

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