re-svgify v1.0.8
π re-svgify β Convert & Customize SVGs as React Components
re-svgify is a powerful tool that transforms your SVG files into optimized, fully customizable React components. No more manual conversionsβjust drop your SVGs in a folder and let re-svgify handle the rest!
π¨ Fully Customizable Icons
βοΈ Change Colors β Modify fill
and stroke
dynamically using props.
βοΈ Adjust Size β Set custom width
and height
for your icons.
βοΈ All SVG Props Supported β Easily pass any SVG attribute like opacity
, strokeWidth
, className
, etc.
π Example: Dynamic Color & Size
<IconArrowDown fill="red" stroke="blue" width={48} height={48} />
β¨ Features
- π¦ Automatic Conversion β Turns
.svg
files into React components (.tsx
). - π¨ Customizable via Props β Modify icon colors, sizes, and styles dynamically.
- π Optimized Output β Minifies, cleans, and simplifies SVGs for better performance.
- π CamelCase Naming β Converts file names like
icon-arrow-down.svg
toIconArrowDown.tsx
. - π§ Flexible Configuration β Customize input/output directories.
π₯ Installation
npm install -g re-svgify
β‘ Usage
- Place your SVG files inside the
_icons/
folder in your project root. Run the CLI command:
npx re-svgify
Find your generated components inside
components/icons/
.
π Example
π¨ Input (_icons/arrow-down.svg
)
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M12 19l-7-7h14z"/>
</svg>
π Output (components/icons/IconArrowDown.tsx
)
import BaseIcon from "../base-icon";
import { SvgIcon } from "../icon.types";
export default function IconArrowDown(props: SvgIcon) {
return (
<BaseIcon {...props}>
<path d="M12 19l-7-7h14z" />
</BaseIcon>
);
}
π Usage with Custom Styles
<IconArrowDown fill="green" stroke="black" strokeWidth={2} width={32} height={32} />
βοΈ Configuration
By default, re-svgify looks for _icons/
and outputs components to components/icons/
. You can modify this in gulpfile.cjs
.
To customize the output directory:
npx re-svgify --iconsFolder ./my-icons --componentsFolder ./src/components/icons
π‘ Why Use re-svgify?
β
Saves time β No more manual React conversions!
β
Performance-focused β Minified, clean SVGs for better rendering.
β
Fully customizable β Change colors, sizes, and styles dynamically.
β
Zero setup β Just run and generate!
π©βπ» Contributing
Found a bug? Have a feature request? Open an issue or contribute via PR!
π License
MIT License. Free to use, modify, and share.
π Transform & customize your icons effortlessly with re-svgify! π¨π‘