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:
- 5000+ SVG icons across 5 different styles
- Need for React, Vue, React Native, and Svelte components
- Consistent theming and accessibility requirements
- Maintaining folder structure and naming conventions
- Optimizing for performance while preserving visual quality
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/- π― Zero Configuration - Works out of the box with sensible defaults
- π§ Intelligent Style Detection - Auto-detects stroke, solid, contrast, and duotone icons
- π¨ Advanced Theming - Converts colors to
currentColorwhile preserving visual intent - β‘ Multi-Framework Support - React JSX/TSX, Vue, React Native, Svelte
- π Structure Preservation - Maintains your folder organization
- π§ Powerful CLI - Comprehensive options with subcommands
- βΏ Accessibility Built-in - ARIA attributes and semantic markup
- π§Ή Auto-Cleanup - Manages temporary files automatically
- π Production Ready - Battle-tested on 5000+ icons in Pikaicons
- π‘ Robust Sanitisation - Fixes malformed SVG tags & removes duplicate attributes automatically
# 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-afterFlexible 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 attributescontrast- Icons with both stroke and fillduo-stroke- Two-tone outline iconsduo-solid- Two-tone filled icons
output/
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:
- Prefix:
Pi(inspired by PikaIcons, customizable) - Format:
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 outputsnpm 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,vueIconPackr uses a sophisticated two-stage pipeline:
- SVG Preprocessing - SVGO optimization with style-aware transformations
- Component Generation - Framework-specific component creation with theming
Key Technologies:
- SVGO - Advanced SVG optimization
- Commander.js - Comprehensive CLI interface
- Chalk & Ora - Beautiful terminal output
- Glob - Flexible file discovery
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and add tests
- Commit:
git commit -am 'Add new feature' - Push:
git push origin feature-name - Submit a pull request
- Added automated SVG sanitisation that removes duplicate attributes and fixes malformed tags, preventing error-SVG patterns in generated components.
- Expanded
.gitignoreto cover build artefacts, cache, and editor folders. - Introduced
CONTRIBUTING.mdwith guidelines for bug reports and pull requests. - Minor docs cleanup and standardisation.
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.