https://github.com/elrumordelaluz/svg-spreact
Create svg sprites using svgson and react
https://github.com/elrumordelaluz/svg-spreact
icons react svg svg-files svg-icons svg-spreact svg-sprite svg-sprites svgo svgson
Last synced: 3 months ago
JSON representation
Create svg sprites using svgson and react
- Host: GitHub
- URL: https://github.com/elrumordelaluz/svg-spreact
- Owner: elrumordelaluz
- Created: 2018-04-21T09:17:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-24T02:12:08.000Z (over 2 years ago)
- Last Synced: 2025-07-04T03:06:40.284Z (3 months ago)
- Topics: icons, react, svg, svg-files, svg-icons, svg-spreact, svg-sprite, svg-sprites, svgo, svgson
- Language: JavaScript
- Homepage: https://svgsprit.es
- Size: 682 KB
- Stars: 14
- Watchers: 3
- Forks: 6
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
Create an SVG Sprites using svgson and react## Install
```zsh
yarn add svg-spreact
```## Usage
```
const svgSpreact = require('svg-spreact')const icons = [
`
Add
`,
`
Checkmark
`
]svgSpreact(icons).then(({ defs, refs }) => {
console.log(defs) //
console.log(refs) //
})
```## API
svgSpreact(input, [options])
#### input
Type: `Array`
#### options
Type: `Object`
* `tidy` output prettyfied (`Boolean`) default: `true`
* `optimize` output optimizde with [svgo](https://github.com/svg/svgo/) (`Boolean`) default: `true`
* `svgoConfig` _SVGO_ plugins configuration (`Object`) [default](https://github.com/elrumordelaluz/svg-spreact/blob/master/index.js#L25-L45)
* `processId` function for customize _Icons_ `id`s (`Function`) default: `(n) => 'Icon_' + n`
* `className` classname/s to add on each `` element (`String`) default: ''## Example
Take a look into [this example](https://github.com/elrumordelaluz/svg-spreact/blob/master/example.js) reading a folder with _Icons_
## Related
[svg-spreact-cli](https://github.com/elrumordelaluz/svg-spreact-cli) CLI version
[web-app](https://svgsprit.es)
`[POST]` [endpoint](https://svgsprit.es/api) | [docs](https://github.com/elrumordelaluz/micro-svg-spreact)