{"id":15649182,"url":"https://github.com/egoist/svg-to-component","last_synced_at":"2025-04-30T15:24:14.398Z","repository":{"id":45275068,"uuid":"100158454","full_name":"egoist/svg-to-component","owner":"egoist","description":"Convert SVG to React/Vue components","archived":false,"fork":false,"pushed_at":"2021-12-25T14:31:27.000Z","size":59,"stargazers_count":40,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T15:24:07.986Z","etag":null,"topics":["component","react","svg","vue"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/egoist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-13T06:29:44.000Z","updated_at":"2022-06-17T09:50:07.000Z","dependencies_parsed_at":"2022-09-06T12:10:16.056Z","dependency_job_id":null,"html_url":"https://github.com/egoist/svg-to-component","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fsvg-to-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fsvg-to-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fsvg-to-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fsvg-to-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egoist","download_url":"https://codeload.github.com/egoist/svg-to-component/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251730040,"owners_count":21634319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","react","svg","vue"],"created_at":"2024-10-03T12:28:35.477Z","updated_at":"2025-04-30T15:24:14.378Z","avatar_url":"https://github.com/egoist.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# svg-to-component\n\n[![NPM version](https://img.shields.io/npm/v/svg-to-component.svg?style=flat)](https://npmjs.com/package/svg-to-component) [![NPM downloads](https://img.shields.io/npm/dm/svg-to-component.svg?style=flat)](https://npmjs.com/package/svg-to-component) [![CircleCI](https://circleci.com/gh/egoist/svg-to-component/tree/master.svg?style=shield)](https://circleci.com/gh/egoist/svg-to-component/tree/master)  [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000\u0026style=flat)](https://github.com/egoist/donate)\n\n## Install\n\n```bash\nyarn add svg-to-component\n```\n\n## Usage\n\n```js\nconst Svg2Component = require('svg-to-component')\n\n// Generate React component from SVG string\nnew Svg2Component()\n  //...........svg string, component name\n  .fromString('\u003csvg ...', 'MyIcon')\n  .toReactComponent()\n  // export default function MyIcon(props) {\n  //   return \u003csvg ...\u003e\n  // }\n\n// You can also directly generate component from an SVG file\nnew Svg2Component()\n  .fromFileSync('./my-icon.svg', 'optional-component-name')\n  .toVueComponent()\n```\n\n## API\n\n```js\nconst svg2component = new Svg2Component()\n```\n\n### svg2component.fromString(str, name)\n\n#### str\n\nSVG string.\n\n#### name\n\nCould be either of:\n\n- Component name, either in `kebab-case` or `PascalCase`.\n- File path, we extract component name from it.\n\n### svg2component.fromFile(filename, [name])\n\nReturn a Promise.\n\n#### filename\n\nPath to SVG file.\n\n#### name\n\nComponent name.\n\n### svg2component.fromFileSync(filename, [name])\n\nLike `.fromFile` but sync and return `this`\n\n### svg2component.toReactComponent([opts])\n\nReturn a string which represents a React component.\n\n#### opts\n\n##### transformJSX\n\nType: `boolean`\u003cbr\u003e\nDefault: `true`\n\n### svg2component.toVueComponent([opts])\n\nReturn a string which represents a Vue component.\n\n#### opts\n\n##### transformJSX\n\nType: `boolean`\u003cbr\u003e\nDefault: `true`\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n\n## Author\n\n**svg-to-component** © [EGOIST](https://github.com/egoist), Released under the [MIT](./LICENSE) License.\u003cbr\u003e\nAuthored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/svg-to-component/contributors)).\n\n\u003e [github.com/egoist](https://github.com/egoist) · GitHub [@EGOIST](https://github.com/egoist) · Twitter [@_egoistlily](https://twitter.com/_egoistlily)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fsvg-to-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegoist%2Fsvg-to-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fsvg-to-component/lists"}