Create Svelte components from Iconify SVG icons with type-safe support. A simple CLI tool for generating Svelte icons.
Svelicon streamlines the process of using Iconify icons in your Svelte projects, offering TypeScript support and flexible customization.
npx svelicon search "home" --collection mdi
Choose from the search results using numbers, ranges, or "all"
Icons are downloaded with tsconfig validation and progress tracking
<script>
import HomeIcon from '$icons/MdiHome.svelte';
</script>
<HomeIcon size={1.5} class="text-blue-500" />
Search through thousands of icons interactively:
# Search for icons
npx svelicon search "arrow"
# Search within a specific collection
npx svelicon search "home" --collection mdi
# Search and browse without downloading
npx svelicon search "user" --no-download
# Advanced search with filters
npx svelicon search "database" --collection lucide --limit 30
npx svelicon download "mdi:home"
# Download multiple icons at once
npx svelicon download "mdi:home,lucide:star,heroicons:user"
# Batch download with custom concurrency
npx svelicon download "mdi:home,mdi:user,lucide:star" --concurrent 20
npx svelicon fluent/person-passkey-28-filled
npx svelicon search <query> [options]
Options:
-c, --collection <name> Filter by icon collection (e.g., mdi, lucide)
--category <name> Filter by category
-l, --limit <number> Number of results to show (default: 20)
-o, --output <dir> Output directory (default: "src/icons")
--withts Generate TypeScript version (default: true)
--withjs Generate JavaScript version
--concurrent <number> Concurrent downloads (default: 10)
--skip-tsconfig Skip tsconfig.json validation
--no-download Only search, don't download
npx svelicon download <icons> [options]
Arguments:
<icons> Icon name or comma-separated list
Options:
-o, --output <dir> Output directory (default: "src/icons")
--withts Generate TypeScript version (default: true)
--withjs Generate JavaScript version
-c, --concurrent <number> Concurrent downloads for batch (default: 10)
--skip-tsconfig Skip tsconfig.json validation
Svelicon automatically validates your tsconfig.json
and suggests the optimal configuration:
{
"compilerOptions": {
"paths": {
"$icons": ["src/icons"],
"$icons/*": ["src/icons/*"]
}
}
}
This enables clean imports:
import HomeIcon from '$icons/MdiHome.svelte';
All generated components accept these props:
interface IconProps {
size?: number; // Icon size in em units
class?: string; // Add custom CSS classes to the SVG element
}
<script>
import HomeIcon from '$icons/MdiHome.svelte';
import StarIcon from '$icons/LucideStar.svelte';
</script>
<HomeIcon size={1.2} />
<StarIcon class="text-yellow-500" />
<script lang="ts">
import HomeIcon, { type MdiHomeProps } from '$icons/MdiHome.svelte';
let iconProps: MdiHomeProps = {
size: 1.2,
class: 'my-custom-icon'
};
</script>
<HomeIcon {...iconProps} />
<script>
import HomeIcon from './icons/MdiHome.svelte';
</script>
<HomeIcon size={1.2} />
Generated components include:
<script lang="ts" module>
export interface MdiHomeProps {
size?: number;
class?: string;
}
</script>
<script lang="ts">
const { size = 0.7, class: className = '' }: MdiHomeProps = $props();
</script>
<svg
xmlns="http://www.w3.org/2000/svg"
width="{size}em"
height="{size}em"
viewBox="0 0 24 24"
class="{className}">
<!-- optimized SVG path data -->
</svg>
Contributions are welcome! Please read our Contributing Guide for details.
MIT © Friend of Svelte
If you find this Svelte icon library helpful, please consider:
Made with ❤️ by Friend of Svelte