Skip to content

πŸ”§ Convert SVG icons into framework-friendly components for React, Vue, Svelte, and Angular β€” accessible, customizable, and type-safe.

Notifications You must be signed in to change notification settings

IqboljonHasan/svg-to-react-vue-angular-svelte-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

svg-to-react-vue-angular-svelte-component

Convert your SVG icons (e.g. from Figma) into reusable components for React, Vue, Svelte, and Angular β€” all with proper props, accessibility support, and TypeScript.


✨ Features

  • 🧠 Framework-agnostic SVG parser
  • βš›οΈ React components using a custom withSvg HOC
  • πŸ”₯ Vue 3 <script setup> SFCs
  • 🟠 Svelte components with full reactivity
  • πŸ…°οΈ Angular standalone components
  • 🎨 All icons support size, color, strokeWidth, fill, title, aria-hidden, role
  • 🧹 Cleans output directories before generation
  • πŸ“¦ Outputs tree-shakable files with named exports

πŸš€ Usage

1. Install

npm install

2. Add your .svg icons

Put them in:

src/icons-svg/

3. Run Generators

npm run generate:react
npm run generate:vue
npm run generate:svelte
npm run generate:angular
npm run generate:all   # To generate all at once

πŸ“¦ Import Examples

βœ… React

import { AddIcon } from "@/components/icons"
<AddIcon size={24} color="blue" title="Add" />

βœ… Vue

<AddIcon size="32" color="red" title="Add item" />

βœ… Svelte

<AddIcon size={20} color="green" title="Submit" />

βœ… Angular

<icon-add [size]="28" color="purple" [title]="'Delete'" />

πŸ’‘ Icon Props (All Frameworks)

Prop Type Description
size number Icon size in pixels
color string Stroke color (currentColor default)
strokeWidth number Stroke width (default: 1.5)
fill string Fill color (none default)
title string Accessible label (renders <title>)
ariaHidden boolean Whether to hide from screen readers
role string Accessibility role (img, presentation)

πŸ“œ Scripts

"scripts": {
  "generate:react": "ts-node src/main.ts react",
  "generate:vue": "ts-node src/main.ts vue",
  "generate:svelte": "ts-node src/main.ts svelte",
  "generate:angular": "ts-node src/main.ts angular",
  "generate:all": "npm run generate:react && npm run generate:vue && npm run generate:svelte && npm run generate:angular"
}

πŸ“ƒ License

MIT


πŸ™Œ Credits

Built with ❀️ to streamline icon usage across modern frontend frameworks.

About

πŸ”§ Convert SVG icons into framework-friendly components for React, Vue, Svelte, and Angular β€” accessible, customizable, and type-safe.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published