Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

svgr

> 前端框架
Open source

Transform SVGs into React components

11.0K stars0 likes1 views
WebsiteGitHub

About

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.

Docs

See the documentation at react-svgr.com for more information about using svgr!

Quicklinks to some of the most-visited pages:

  • Playground
  • Getting started
  • CLI usage
  • Webpack usage
  • Node.js usage

Example

Take a SVG:

…

Run SVGR

bash
npx @svgr/cli --icon --replace-attr-values "#063855=currentColor" -- icon.svg

Get an optimized React component

javascript
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 SvgComponent

Supporting SVGR

SVGR 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:

  • Sponsor me on GitHub
  • Become a backer or sponsor on OpenCollective

Learn more about supporting SVGR.

Contributing

Check out the contributing guidelines

License

Licensed under the MIT License, Copyright © 2017-present Greg Bergé.

See LICENSE for more information.

Acknowledgements

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.

Issues· 150 open

View all issuesOpen on GitHub
  • #1032

    bug

    Updated Aug 31, 2026
  • #1029

    brace-expansion DoS via outdated glob in @svgr/cli (GHSA-mh99-v99m-4gvg)

    Updated Jul 28, 2026
  • #1025

    feature: Allow drop-in replacements for svgo

    Updated Jul 18, 2026
  • #731

    prefix the all id attributes with a string, random or customisable

    feature request 🙏Updated Jul 16, 2026
  • #1027

    Support for Babel 8

    Updated Jun 23, 2026
  • #1026

    Is this lib maintained for vulnerabilities? or would you advice alternative?

    Updated Apr 9, 2026
  • #883

    SVG being downloaded client side in a 'server only' component NextJS

    Updated Mar 28, 2026
  • #1024

    Could not find a declaration file for module '@babel/core'.

    Updated Mar 22, 2026
  • #1020

    SVGR strips px from CSS variables in inline styles

    Updated Feb 4, 2026
  • #1018

    @svgr/webpack with `jsxRuntime: 'classic-preact'` emits `React` namespace usage

    Updated Feb 1, 2026

> Tags

TypeScriptinline-svgloaderreactreact-native

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架