Transform SVGs into React components
Transform SVGs into React components
[**Try it out online!**](https://react-svgr.com/playground)Watch the talk at React Europe
SVGR is an universal tool to transform SVG into React components.
SVGR takes a raw SVG and transforms it into a ready-to-use React component.
See the documentation at react-svgr.com for more information about using svgr!
Quicklinks to some of the most-visited pages:
Take a SVG:
…Run SVGR
npx @svgr/cli --icon --replace-attr-values "#063855=currentColor" -- icon.svgGet an optimized React component
import * as React from 'react'
const SvgComponent = (props) => (
<svg width="1em" height="1em" viewBox="0 0 48 1" {...props}>
<path d="M0 0h48v1H0z" fill="currentColor" fillRule="evenodd" />
</svg>
)
export default SvgComponentSVGR is a MIT-licensed open source project. It's an independent project with ongoing development made possible thanks to the support of these awesome backers. If you'd like to join them, please consider:
Learn more about supporting SVGR.
Check out the contributing guidelines
Licensed under the MIT License, Copyright © 2017-present Greg Bergé.
See LICENSE for more information.
This project has been popularized by Christopher Chedeau and it has been included in create-react-app thanks to Dan Abramov. We would like to thanks Sven Sauleau for his help and its intuition.
bug
brace-expansion DoS via outdated glob in @svgr/cli (GHSA-mh99-v99m-4gvg)
feature: Allow drop-in replacements for svgo
prefix the all id attributes with a string, random or customisable
Support for Babel 8
Is this lib maintained for vulnerabilities? or would you advice alternative?
SVG being downloaded client side in a 'server only' component NextJS
Could not find a declaration file for module '@babel/core'.
SVGR strips px from CSS variables in inline styles
@svgr/webpack with `jsxRuntime: 'classic-preact'` emits `React` namespace usage