v0.0.1
A tiny Svelte 5 component library that exposes Microsoft Fluent System Icons as Svelte components. Icons are sourced from @iconify-json/fluent and compiled into tree-shakeable modules.
svelte-fluent-icon@iconify-json/fluent using a small generator script (generate-icon.ts)# with pnpm
pnpm add svelte-fluent-icon
# with npm
yarn add svelte-fluent-icon
# with yarn
npm i svelte-fluent-icon
There are two ways to import icons:
<script>
// 20px, filled variant
import { AccessTimeIcon } from 'svelte-fluent-icon/icon/20/filled';
</script>
<AccessTimeIcon width={20} height={20} aria-label="Access time" />
<script>
// Name is suffixed with size+style
import { AccessTime20FilledIcon } from 'svelte-fluent-icon';
</script>
<AccessTime20FilledIcon class="text-gray-700" aria-hidden />
Notes
pre render function and the default children render function are supported internally by the generator, allowing advanced composition if needed.Icons are generated in these sizes and styles (matching Fluent icons availability):
Import paths follow:
svelte-fluent-icon/icon/<size>/<style> for per-folder named exports (e.g. AccessTimeIcon)AccessTime20FilledIcon)The generator (generate-icon.ts) reads Fluent icon metadata and creates Svelte components under src/lib/icon/<size>/<style>. For each icon it:
@iconify/utils (iconToSVG, iconToHTML, replaceIDs)<Name>.svelte with Svelte 5 render hooks (pre, children) and forwards all remaining SVG propsindex.ts files so you can import either by folder or via the package rootYou can regenerate icons locally with:
pnpm run generate
This will clean previously generated folders and build fresh components.
These are the most relevant commands from package.json:
pnpm run generate — regenerate icons from @iconify-json/fluentpnpm run prepack — clean, generate, sync, and package the librarypnpm run build — app build then prepack the librarypnpm run check — typecheck via svelte-checkType definitions for the library are emitted to dist. The package exports map exposes both Svelte and types for root and per-folder entry points.
MIT — see the LICENSE file.
@iconify-json/fluent@iconify/utils@sveltejs/package