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 fluent/person-passkey-28-filled
This command downloads the person-passkey-28-filled
icon from the fluent
collection and creates a TypeScript Svelte component at
src/icons/FluentPersonPasskey28Filled.svelte
npx svelicon [options] [collection]/[icon]
Options:
-o, --output <dir> Output directory (default: "src/icons")
--withts Generate TypeScript version (default: true)
--withjs Generate JavaScript version
-h, --help Display help for command
Example:
npx svelicon --withjs fluent/person-passkey-28-filled
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 FluentPersonPasskey28Filled from './icons/FluentPersonPasskey28Filled.svelte';
</script>
<FluentPersonPasskey28Filled size={1.2} />
<script lang="ts">
import FluentPersonPasskey28Filled, { type FluentPersonPasskey28FilledProps } from './icons/FluentPersonPasskey28Filled.svelte';
let iconProps: FluentPersonPasskey28FilledProps = {
size: 1.2,
class: 'my-custom-icon'
};
</script>
<FluentPersonPasskey28Filled {...iconProps} />
Generated components include:
<script lang="ts" module>
export interface FluentPersonPasskey28FilledProps {
size?: number;
class?: string;
}
</script>
<script lang="ts">
const { size = 0.7, class: className = '' }: FluentPersonPasskey28FilledProps = $props();
</script>
<svg class={className}><!-- icon content --></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