A flexible, multi-framework icon library with CLI support for generating icon components from SVG files.
- 🎨 Multi-framework support - React, Vue 3, and Svelte
- 🚀 TypeScript first - Full type safety and IntelliSense support
- 📦 Tree-shakeable - Only bundle the icons you use
- 🛠️ Powerful CLI - Generate icon components from SVG files
- ⚡ Fast and lightweight - Minimal runtime overhead
- 🎯 Customizable - Full control over size, color, and stroke width
- 🔥 Modern - Built with latest tooling and best practices
| Package | Version | Description |
|---|---|---|
| @dawnice/icon-forge-cli | CLI tool for generating icon components | |
| @dawnice/icon-forge-core | Core utilities and types | |
| @dawnice/icon-forge-react | React icon components | |
| @dawnice/icon-forge-vue | Vue 3 icon components | |
| @dawnice/icon-forge-svelte | Svelte icon components |
npm install @dawnice/icon-forge-react
# or
pnpm add @dawnice/icon-forge-react
# or
yarn add @dawnice/icon-forge-reactnpm install @dawnice/icon-forge-vue
# or
pnpm add @dawnice/icon-forge-vuenpm install @dawnice/icon-forge-svelte
# or
pnpm add @dawnice/icon-forge-sveltenpm install -D @dawnice/icon-forge-cli
# or
pnpm add -D @dawnice/icon-forge-cliimport { Icon, ArrowRight } from '@dawnice/icon-forge-react';
function App() {
return (
<div>
{/* Use pre-generated icon */}
<ArrowRight size={24} color="blue" strokeWidth={2} />
{/* Or use the base Icon component */}
<Icon
iconNode={[
['path', { d: 'M5 12h14' }],
['path', { d: 'm12 5 7 7-7 7' }]
]}
size={32}
color="red"
/>
</div>
);
}<template>
<div>
<!-- Use pre-generated icon -->
<ArrowRight :size="24" color="blue" :stroke-width="2" />
<!-- Or use the base Icon component -->
<Icon
:iconNode="iconNode"
:size="32"
color="red"
/>
</div>
</template>
<script setup lang="ts">
import { Icon } from '@dawnice/icon-forge-vue';
import { ArrowRight } from '@dawnice/icon-forge-vue/icons';
const iconNode = [
['path', { d: 'M5 12h14' }],
['path', { d: 'm12 5 7 7-7 7' }]
];
</script><script lang="ts">
import { Icon } from '@dawnice/icon-forge-svelte';
import ArrowRight from '@dawnice/icon-forge-svelte/icons/ArrowRight.svelte';
const iconNode = [
['path', { d: 'M5 12h14' }],
['path', { d: 'm12 5 7 7-7 7' }]
];
</script>
<!-- Use pre-generated icon -->
<ArrowRight size={24} color="blue" strokeWidth={2} />
<!-- Or use the base Icon component -->
<Icon {iconNode} size={32} color="red" />The CLI tool helps you generate icon components from SVG files.
npx icon-forge initThis will create an icon-forge.config.ts file with the following options:
import { defineConfig } from '@dawnice/icon-forge-cli';
export default defineConfig({
// Target framework: 'react' | 'vue' | 'svelte'
framework: 'react',
// Input directory containing SVG files
input: './icons',
// Output directory for generated components
output: './src/icons',
// Generate TypeScript files
typescript: true,
// Optimize SVG files using SVGO
optimize: true,
// Transform icon names (optional)
transform: (iconName) => iconName,
// SVGO configuration (optional)
svgoConfig: {
plugins: [
'preset-default',
'removeViewBox'
]
}
});npx icon-forge generateThis will:
- Read SVG files from the input directory
- Optimize them (if enabled)
- Parse the SVG structure
- Generate framework-specific components
- Create an index file for easy importing
npx icon-forge watchAutomatically regenerate icons when SVG files change.
All icon components accept the following props:
| Prop | Type | Default | Description |
|---|---|---|---|
size |
number | string |
24 |
Icon size (width and height) |
color |
string |
'currentColor' |
Stroke color |
strokeWidth |
number | string |
2 |
Stroke width |
className / class |
string |
'' |
Additional CSS classes |
React and Vue components also accept all standard SVG attributes.
Check out the example projects in the examples/ directory:
This is a monorepo managed with pnpm and Turborepo.
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Run development mode
pnpm devContributions are welcome! Please feel free to submit a Pull Request.
MIT © Xiaobing Zhu