• SVG
  • SVGIcon
  • SVGIconsPreviewer
Max width:
40%
Force Centering
Use scope
SVG
@opuscapita/react-svg
@
3.0.2

Reset code

Component Name

SVG

Synopsis

Simple SVG renderer

Props Reference

NameTypeDescription
classNamestringDefault behaviour
stylestringWrite a description of the property
svgstringWrite a description of the property

Code Example

<SVG
  style={{ width: '100px', height: '100px', fill: '#000' }}
  svg={`
    <svg viewBox="0 0 120 120" version="1.1">
      <circle cx="60" cy="60" r="50"/>
    </svg>
  `}
/>

Tips

You can require an SVG file content using webpack.

let ShoppingCartIcon = require('!!raw-loader!@opuscapita/svg-icons/lib/add_shopping_cart.svg');

...
<SVG
  svg={ShoppingCartIcon}
/>
...

Don't forget install raw-loader:
npm install --save-dev -E raw-loader