
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
Convert SVG icons into React components
npm i pixo
Pass a directory or SVG file path as the first argument.
$ pixo src --out-dir dist
Each SVG icon will be automatically optimized and renamed to a pascal case filename for the component. Icon components can then be imported into a React application.
import React from 'react'
import CheckIcon from './CheckIcon'
const App = props => (
<div>
<CheckIcon />
</div>
)
The default component template includes props for:
size (number) pixel width and height (default 24)color (string) color value passed to the SVG fill attribute (default 'currentcolor')Each SVG icon must conform to the following:
viewBox attribute, preferably 0 0 24 24<path> elementsPixo includes experimental support for <circle>, <polygon>, and <rect> elements.
The following elements will be ignored:
<defs> or <clipPath>fill="none" attribute<ellipse> elements<line> elements<polyline> elements<path> elementsMost graphics applications can convert shapes into SVG paths.
Compound Path commandPixo uses a default template for rendering, but includes some built-in options.
default: plain SVG with no stylingstyledSystem: styled-component with margin, padding, and color props from styled-systemTo use a custom template, pass a path to your template to the --template flag.
pixo icons --template custom-template.js
A template should be a function that returns a string for the component source code, written as a Node.js module.
// default template
module.exports = ({
name,
viewBox,
pathData
}) => `import React from 'react'
const ${name}Icon = ({
size,
color,
...props
}) => (
<svg
{...props}
viewBox='${viewBox}'
width={size}
height={size}
fill={color}
>
<path d='${pathData}' />
</svg>
)
${name}Icon.displayName = '${name}Icon'
${name}Icon.defaultProps = {
size: 24,
color: 'currentcolor'
}
export default ${name}`
Template function arguments
name camel cased name that can be used for the component nameviewBox the original viewBox value from the SVGpathData extracted path data for the <path> element's d attributeOptions can be passed as flags to the CLI or added to a pixo field in your package.json
Run pixo --help to see the list of options.
outDir (string) output directory (default dist)template (string) name of built-in template or path to custom templateindex (boolean) create an index.js barrel moduleiconComponent (boolean) create an Icon.js wrapper componentrecursive (boolean) recursively read all SVGs in subdirectoriesCLI flags
-d --out-dir Output directory
-t --template Name of built-in template or path to custom template
-i --index Include index.js barrel module
-c --icon-component Include wrapper Icon.js component
-r --recursive Recursively read all SVGs in subdirectories
Example package.json
{
"pixo": {
"outDir": "dist",
"template": "./custom-template.js",
"index": true,
"iconComponent": true,
"recursive": true
}
}
FAQs
Convert SVG icons into React components
The npm package pixo receives a total of 141 weekly downloads. As such, pixo popularity was classified as not popular.
We found that pixo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.