An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          


SVG Spreact


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)