{"id":16327075,"url":"https://github.com/mrmlnc/svg2sprite","last_synced_at":"2025-03-22T22:31:07.347Z","repository":{"id":57375658,"uuid":"65678691","full_name":"mrmlnc/svg2sprite","owner":"mrmlnc","description":":fireworks: A very simple module to generate SVG sprites.","archived":false,"fork":false,"pushed_at":"2017-05-04T17:29:15.000Z","size":53,"stargazers_count":10,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T15:21:32.089Z","etag":null,"topics":["icons","sprites","svg","svg-sprites"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mrmlnc.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":"2016-08-14T17:41:29.000Z","updated_at":"2022-10-12T01:55:19.000Z","dependencies_parsed_at":"2022-09-07T13:40:20.343Z","dependency_job_id":null,"html_url":"https://github.com/mrmlnc/svg2sprite","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fsvg2sprite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fsvg2sprite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fsvg2sprite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fsvg2sprite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrmlnc","download_url":"https://codeload.github.com/mrmlnc/svg2sprite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245028475,"owners_count":20549524,"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":["icons","sprites","svg","svg-sprites"],"created_at":"2024-10-10T23:10:19.670Z","updated_at":"2025-03-22T22:31:07.021Z","avatar_url":"https://github.com/mrmlnc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svg2sprite\n\n\u003e A very simple module to generate SVG sprites.\n\n[![Travis Status](https://travis-ci.org/mrmlnc/svg2sprite.svg?branch=master)](https://travis-ci.org/mrmlnc/svg2sprite)\n\n## Install\n\n```shell\n$ npm i -D svg2sprite\n```\n\n## Why?\n\nExisting solutions have many dependencies.\n\n## Usage\n\n```js\nconst svgSprite = require('svg2sprite');\nconst sprite = svgSprite.collection({ inline: true });\n\nsprite.add('chevron-up', '\u003csvg\u003e\u003cpath d=\"M10 10l-1.5 1.5L5 7.75 1.5 11.5 0 10l5-5z\"\u003e\u003c/path\u003e\u003c/svg\u003e');\nsprite.add('chevron-down', '\u003csvg\u003e\u003cpath d=\"M5 11L0 6l1.5-1.5L5 8.25 8.5 4.5 10 6z\"\u003e\u003c/path\u003e\u003c/svg\u003e');\n\nconst svg = sprite.compile();\n\nconsole.log(svg);\n// \u003csvg position=\"absolute\" height=\"0\" width=\"0\"\u003e\n//   \u003csymbol id=\"chevron-up\"\u003e\u003cpath d=\"M10 10l-1.5 1.5L5 7.75 1.5 11.5 0 10l5-5z\"\u003e\u003c/path\u003e\u003c/symbol\u003e\n//   \u003csymbol id=\"chevron-down\"\u003e\u003cpath d=\"M5 11L0 6l1.5-1.5L5 8.25 8.5 4.5 10 6z\"\u003e\u003c/path\u003e\u003c/symbol\u003e\n// \u003c/svg\u003e\n```\n\n## Supported methods\n\n#### `.collection([options])`\n\nThis method creates a new item collection and returns the available methods for it. See all available [options](#supported-options).\n\n#### `.add(name, content, options)`\n\nThis method adds an item to the collection. Using the last argument you can transfer individual settings for that item (e.g. `attributes`). See all available [options](#supported-options).\n\n#### `.get(name)`\n\nReturns the contents of a specified element.\n\n#### `.remove(name)`\n\nRemoves the specified item from the collection.\n\n#### `.clean()`\n\nRemoves all elements in the collection.\n\n#### `.compile()`\n\nReturns the builded sprite.\n\n## Supported options\n\n#### rootAttributes\n\n  * Type: `Object`\n  * Default: `{}`\n\nThe attributes that will be added to the root `svg` tag.\n\n#### inline\n\n  * Type: `Boolean`\n  * Default: `false`\n\nIf you want to embed the sprite into your HTML source, you will want to set this to `true` in order to prevent the creation of SVG namespace declarations and to set some other attributes for effectively hiding the library sprite.\n\n#### iconAttributes\n\n  * Type: `Object`\n  * Default: `{}`\n\nThe attributes of each icon. Current attribute values will be overwritten.\n\n#### iconPrefix\n\n  * Type: `String`\n  * Default: `''`\n\nThe name prefix for each icon.\n\n#### iconSuffix\n\n  * Type: `String`\n  * Default: `''`\n\nThe name suffix for each icon.\n\n#### clean.stripEmptyTags\n\n  * Type: `Boolean`\n  * Default: `true`\n\nRemoves empty tags such as `\u003cdefs\u003e\u003c/defs\u003e` or `\u003cg\u003e\u003c/g\u003e`.\n\n#### clean.stripTags\n\n  * Type: `Array`\n  * Default: `['title', 'desc']`\n\nRemoves tags, that are listed in this list.\n\n#### clean.stripAttrs\n\n  * Type: `Array`\n  * Default: `[]`\n\nRemoves attributes, that are listed in this list.\n\nIf you specify a string, then use the strict comparison. You can also specify the object and the type of comparison.\n\n```js\n{\n  clean: {\n    stripAttrs: [\n      // true for: style=\"..\"\n      'style',\n      // true for: stoke=\"..\", stoke-width=\"..\", etc.\n      { pattern: 'stroke', strict: false }\n    ]\n  }\n}\n```\n\n#### clean.stripExtraAttrs\n\n  * Type: `Boolean`\n  * Default: `true`\n\nRemoves Sketch and xmlns:* attributes.\n\n#### clean.stripStyles\n\n  * Type: `Boolean|Array`\n  * Default: `true`\n\nRemoves `style` attributes from SVG definitions, or a list of the properties that will be removed from `style` tag and atrribute.\n\n## Related\n\n  * [svg2sprite-cli](https://github.com/mrmlnc/svg2sprite-cli) - CLI interface for this module.\n  * [yellfy-svg-sprite](https://github.com/mrmlnc/yellfy-svg-sprite) - svg2sprite wrapper for easy integration into the development process.\n\n## Changelog\n\nSee the [Releases section of our GitHub project](https://github.com/mrmlnc/svg2sprite/releases) for changelogs for each release version.\n\n## License\n\nThis software is released under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmlnc%2Fsvg2sprite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrmlnc%2Fsvg2sprite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmlnc%2Fsvg2sprite/lists"}