Gathering detailed insights and metrics for react-from-svg
Gathering detailed insights and metrics for react-from-svg
Gathering detailed insights and metrics for react-from-svg
Gathering detailed insights and metrics for react-from-svg
react-native-svg-uri
Render an SVG Image from an URL
react-svgmt
Convenient SVG loading and manipulation from react
react-svg-icon-generator
Generate React Icon Component from SVG icons to show, resize and recolor them.
react-remote-svg
A React component that fetches an SVG from a URL and allows dynamic styling.
Transform SVG files into React components (native | web, JavaScript | TypeScript).
npm install react-from-svg
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (70.33%)
JavaScript (29.67%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
61 Stars
133 Commits
5 Forks
3 Watchers
1 Branches
4 Contributors
Updated on Jun 18, 2025
Latest Version
8.0.0
Package Id
react-from-svg@8.0.0
Unpacked Size
20.12 kB
Size
6.36 kB
File Count
8
NPM Version
10.9.0
Node Version
22.10.0
Published on
Apr 29, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
7
Transform SVG files into React components, Native and/or Web, JavaScript and/or TypeScript. Without minimal dependencies.
1npm install react-from-svg
1react-from-svg --help 2 3Usage 4 $ react-from-svg <sourcePath> <outputPath> [--with-native|--with-web] 5 6Options 7 --with-native, -rn Output code for react-native-svg 8 --with-native-for-typescript, -rnts Output code for react-native-svg with TypeScript 9 --with-web, -rnw Output code for DOM. If --with-native is also used, will be output as .web.js files 10 --with-web-for-typescript, -rnwts Output code for DOM with TypeScript. If --with-native is also used, will be output as .web.tsx files 11 --remove-fill, -rf Remove all 'fill' properties from SVGs, convenient for icons 12 --remove-stroke, -rs Remove all 'stroke' properties from SVGs, convenient for icons 13 --allow-override-fill, -aof --allow-override-fill, -aof Replace all 'fill' properties by a dynamic prop (fills) in SVGs, e.g. fill={fills[N]}. 14 15Example 16 $ react-from-svg src/svgs src/svgs/components --with-web-for-typescript --allow-override-fill
Generated components will allow you to inject all the props you could use on an <svg>
/<Svg>
, such as:
width
height
fill
(if you use --remove-fill
)stroke
(if you use --remove-stroke
)style
⚠️ To see what you can expect from the transformations, check our snapshots 👀
--with-web(-*)
Need you to have:
Note: if you use React Native for Web, see requirements below.
--with-native(-*)
Need you to have:
react-native-svg
--remove-fill
Remove all fill
properties from SVGs, convenient for icons.
--remove-stroke
Remove all stroke
properties from SVGs, convenient for icons.
--allow-override-fill
Replace all fill
properties by a dynamic prop (fills) in SVGs, e.g. fill={fills[N]}.
If fills[N]
is undefined, fallback to the original value (except if --remove-fill
is used). Useful to dynamically control icon color(s).
--allow-override-fill
and childrenWhen using --allow-override-fill
, you can pass children to the component to override the fill(s).
You can for example update a black SVG path to one using a gradient.
Assuming you have a SVG in src/svgs/logo.svg
, let's generate an SVG component :
1react-from-svg src/svgs src/svgs/components --with-web-for-typescript
You should have an SVG component in src/svgs/components/SVGLogo.tsx
.
Now let's boost this SVG component to use a gradient.
1import SVGLogo from "@/src/svgs/components/SVGLogo"; 2import { colors } from "@/src/tokens.stylex"; // your colors could be just a simple object 3 4const logoGradientId = "logo-gradient-id"; 5export default function LogoWithGradient() { 6 return ( 7 <SVGLogo width={149} height={32} fills={[`url(#${logoGradientId})`]}> 8 <linearGradient x1="50%" y1="100%" x2="50%" y2="0%" id={logoGradientId}> 9 <stop stopColor={colors.textSecondary} offset="0%"></stop> 10 <stop stopColor={colors.textTertiary} offset="100%"></stop> 11 </linearGradient> 12 </SVGLogo> 13 ); 14}
That's it. You started from a simple single color SVG path and ended up with a gradient SVG path.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
7 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 0/27 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More