Transform SVG icon collections into optimized, theme-aware component libraries for multiple frameworks with intelligent style detection and seamless developer experience.
IconPackr was born out of a real need while building PikaIcons - a comprehensive icon library project. As the icon collection grew to thousands of SVGs across multiple styles (stroke, solid, duotone, contrast), manually converting them into framework-specific components became impossible.
The Challenge:
The Solution: What started as a personal script to automate Pikaicons component generation evolved into IconPackr - a sophisticated tool that understands icon semantics, applies intelligent optimizations, and generates production-ready components.
Why Open Source: After seeing how much time and effort this saved in the PikaIcons workflow, I realized other developers and icon library creators could benefit from the same automation. IconPackr represents months of refinement in SVG processing, component generation, and developer experience optimization.
# 1. Install dependencies
npm install
# 2. Place your SVG files in the input folder
# (folder will be auto-created if it doesn't exist)
# 3. Generate components for all frameworks
iconpackr
# That's it! Your components are ready in ./iconpack/output/
currentColor
while preserving visual intent# Clone and install
git clone https://github.com/ash-uxi/iconpackr.git
cd iconpackr
npm install
# Optional: Link globally
npm link
# Uses ./iconpack/input/ and outputs to ./iconpack/output/
iconpackr
# Custom paths
iconpackr ./my-icons ./my-components
# Specific frameworks only
iconpackr --formats react-jsx,vue
# Preview without writing files
iconpackr --dry-run
# Generate React components only
iconpackr --formats react-jsx,react-tsx
# Process with detailed output
iconpackr --verbose
# Skip optimization for faster processing
iconpackr --no-optimize
# Auto-detect icon styles from content
iconpackr --auto-detect-style
# Available formats: react-jsx, react-tsx, vue, react-native, svelte
iconpackr --formats react-jsx,vue
iconpackr --formats react-native
iconpackr --formats svelte
# Auto-detect styles from SVG content (recommended)
iconpackr --auto-detect-style
# Set default style for unclear cases
iconpackr --style stroke
iconpackr --style solid
# Available styles: stroke, solid, contrast, duo-stroke, duo-solid
# Two-stage processing
iconpackr preprocess ./icons # Stage 1: Optimize SVGs
iconpackr --skip-preprocess # Stage 2: Generate components
# Status and cleanup
iconpackr check ./icons # Check processed status
iconpackr clean # Clean temporary files
# Skip SVG optimization (faster, larger files)
iconpackr --no-optimize
# Clean processed files before starting
iconpackr --clean-processed
# Auto-cleanup after completion
iconpackr --cleanup-after
Flexible folder organization is supported:
icons/
stroke/category/icon.svg # Style/category/icon
category/icon.svg # Category/icon (style auto-detected)
icon.svg # Flat structure (auto-categorized)
Supported Icon Styles:
stroke
- Outline icons with stroke attributessolid
- Filled icons with fill attributes contrast
- Icons with both stroke and fillduo-stroke
- Two-tone outline iconsduo-solid
- Two-tone filled iconsoutput/
svgs/style/category/icon.svg # Optimized SVGs
react-jsx/style/category/PiIconNameStyle.jsx
react-tsx/style/category/PiIconNameStyle.tsx
vue/style/category/PiIconNameStyle.vue
react-native/style/category/PiIconNameStyle.jsx
svelte/style/category/PiIconNameStyle.svelte
Component Naming:
Pi
(inspired by PikaIcons, customizable)Pi[IconName][Style]
(e.g., PiHomeStroke
, PiHeartSolid
)All generated components support consistent props:
import { PiHomeStroke } from './components/icons';
<PiHomeStroke
size={24} // number - Icon size
color="#4F46E5" // string - Icon color
className="icon" // string - CSS class
ariaLabel="Home icon" // string - Accessibility label
/>
<template>
<PiHomeStroke
:size="24"
color="#4F46E5"
class="icon"
aria-label="Home icon"
/>
</template>
<script setup>
import PiHomeStroke from './components/icons/PiHomeStroke.vue';
</script>
<script>
import PiHomeStroke from './components/icons/PiHomeStroke.svelte';
</script>
<PiHomeStroke
size={24}
color="#4F46E5"
class="icon"
ariaLabel="Home icon"
/>
IconPackr automatically optimizes SVGs for theming:
/* CSS custom properties */
.icon {
color: var(--icon-color, currentColor);
width: var(--icon-size, 1em);
height: var(--icon-size, 1em);
}
/* Dark mode example */
@media (prefers-color-scheme: dark) {
.icon {
--icon-color: #E5E7EB;
}
}
npm run iconpackr # Basic generation
npm run build # Verbose generation
npm run build-dry # Preview build
npm run build-react # React only
npm run build-vue # Vue only
npm run build-native # React Native only
npm run clean # Clean outputs
npm test # Run all tests
npm run test:react # Test React components
npm run test:vue # Test Vue components
npm run test:performance # Performance tests
npm run test:html-report # Generate HTML report
Option | Description | Default |
---|---|---|
--formats |
Output formats | react-jsx,react-tsx,vue,react-native,svelte |
--auto-detect-style |
Auto-detect icon styles | false |
--style |
Default style when unclear | auto |
--verbose |
Detailed output | false |
--dry-run |
Preview without writing | false |
--no-optimize |
Skip SVG optimization | false |
--clean-processed |
Clean before processing | false |
--cleanup-after |
Auto-cleanup after completion | false |
# Fast iteration - skip optimization
iconpackr --no-optimize --formats react-jsx
# Style development - auto-detect everything
iconpackr --auto-detect-style --verbose
# Full optimization pipeline
iconpackr --clean-processed --verbose
# Specific production formats
iconpackr --formats react-jsx,react-tsx --cleanup-after
# Validation
iconpackr --dry-run --verbose
# Production build
iconpackr --clean-processed --verbose --formats react-jsx,vue
IconPackr uses a sophisticated two-stage pipeline:
Key Technologies:
git checkout -b feature-name
git commit -am 'Add new feature'
git push origin feature-name
.gitignore
to cover build artefacts, cache, and editor folders.CONTRIBUTING.md
with guidelines for bug reports and pull requests.MIT License - see LICENSE file for details.
Built with modern Node.js practices and a focus on developer experience. Special thanks to the SVGO team for excellent SVG optimization capabilities.
Made with โค๏ธ for developers who love clean, efficient icon workflows.