All Projects → c8r → Pixo

c8r / Pixo

Licence: mit
Convert SVG icons into React components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Pixo

Linearicons
Linearicons is the highest quality set of line icons, matching with minimalist UI designs in iOS.
Stars: ✭ 64 (-82.75%)
Mutual labels:  svg, icons, icon
Tabler Icons
A set of over 1400 free MIT-licensed high-quality SVG icons for you to use in your web projects.
Stars: ✭ 10,858 (+2826.68%)
Mutual labels:  svg, icons, icon
Icotar
A free colorful icon avatar generator.
Stars: ✭ 94 (-74.66%)
Mutual labels:  svg, icons, icon
React Icomoon
It allows you to simply view the icons in the selection.json file provided by Icomoon.
Stars: ✭ 48 (-87.06%)
Mutual labels:  svg, icons, icon
React Kawaii
Cute SVG React Components
Stars: ✭ 2,709 (+630.19%)
Mutual labels:  svg, components, icons
Icons
The premium icon font for @uiwjs Component Library. https://uiwjs.github.io/icons
Stars: ✭ 99 (-73.32%)
Mutual labels:  svg, icons, icon
Sb
SVG badges to display
Stars: ✭ 99 (-73.32%)
Mutual labels:  svg, icons, icon
Rmdi
React Material Design Icons – built with Pixo, Styled Components, and Styled System
Stars: ✭ 132 (-64.42%)
Mutual labels:  svg, components, icons
Iconpark
🍎Transform an SVG icon into multiple themes, and generate React icons,Vue icons,svg icons
Stars: ✭ 4,924 (+1227.22%)
Mutual labels:  svg, icons, icon
Svelte Awesome
Awesome SVG icon component for Svelte JS, built with Font Awesome icons. Based on Justineo/vue-awesome
Stars: ✭ 193 (-47.98%)
Mutual labels:  svg, icons, icon
Msvgc
Make React components from your plain SVG files
Stars: ✭ 64 (-82.75%)
Mutual labels:  cli, svg, components
React Native Make
A collection of everyday React Native CLI tools
Stars: ✭ 606 (+63.34%)
Mutual labels:  cli, icons, icon
Faviator
A simple easy favicon generator.
Stars: ✭ 155 (-58.22%)
Mutual labels:  cli, svg, icons
icons-flat-osx
Free Flat icons For OSX
Stars: ✭ 371 (+0%)
Mutual labels:  icons, icon
icons
A world of famous icon packs with easy to use interface
Stars: ✭ 21 (-94.34%)
Mutual labels:  icons, icon
iconoir
A Simple and Definitive Open-Source Icons Library
Stars: ✭ 2,429 (+554.72%)
Mutual labels:  icons, icon
foundational-design-system-proto
A prototype for a foundational design system at Shopify
Stars: ✭ 82 (-77.9%)
Mutual labels:  components, icons
octicons-modular
GitHub Octicons with tree-shaking support and icon-per-file style.
Stars: ✭ 25 (-93.26%)
Mutual labels:  icons, icon
cryptocurrency-icons-font
A webfont for cryptocurrency symbols
Stars: ✭ 21 (-94.34%)
Mutual labels:  icons, icon
Mega Doodles Pack
🔥 Big vector pack with hand-drawn doodles for presentations, social media, blog posts and so on
Stars: ✭ 258 (-30.46%)
Mutual labels:  svg, icons

pixo

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')

SVG Requirements

Each SVG icon must conform to the following:

  • Use a square viewBox attribute, preferably 0 0 24 24
  • Only use a single color (e.g. black)
  • For best results, only use <path> elements
  • Do not use transforms

Pixo includes experimental support for <circle>, <polygon>, and <rect> elements.

The following elements will be ignored:

  • Elements within a <defs> or <clipPath>
  • Elements with the fill="none" attribute
  • <ellipse> elements
  • <line> elements
  • <polyline> elements

Converting SVG shapes into <path> elements

Most graphics applications can convert shapes into SVG paths.

  • Adobe Illustrator: use the Compound Path command
  • Figma: TK
  • Sketch: TK

Templates

Pixo uses a default template for rendering, but includes some built-in options.

Custom Templates

To 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 name
  • viewBox the original viewBox value from the SVG
  • pathData extracted path data for the <path> element's d attribute

Options

Options 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 template
  • index (boolean) create an index.js barrel module
  • iconComponent (boolean) create an Icon.js wrapper component
  • recursive (boolean) recursively read all SVGs in subdirectories

CLI 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
  }
}

Related


MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].