Converts svg files into React Components
> Converts your SVG files into React Components wrapped with @s-ui/atom-icon.
Features:
- Building the components
- Showing up a demo locally
``sh`
$ npm i -SE @s-ui/svg
Add bundling scripts to your package.json
`json`
{
"name": "my-awesome-package",
"version": "1.0.0",
"scripts": {
"prepublishOnly": "sui-svg build",
"start": "npm run prepare && sui-svg demo"
}
}
A src folder with all the .svg files to be converted inside.
A lib folder with the generated components will be created/overridden.
⚠️ Advice: no index.js will be generated inside the lib folder, each component should be imported independently for performance reasons.
`jsx
import YourIcon from 'your-svg-repo/lib/YourIcon'
const YourAwesomeComponent = () =>
Awesome text/
Also, keep in mind, you need to import the needed styles for the icons at least once in your app:
`scss
@import 'your-svg-repo/lib/index';
`Template
Every icon svg will be wrapped using an
The wrapped code is minimal, in order to avoid performance penalties. You could check it here.