Easy way to use Heroicons in your Svelte project.
npm i heroicons-for-svelteComponent.svelte
<script>
import Icon from "heroicons-for-svelte";
import { Bell } from "heroicons-for-svelte/icons/outline";
</script>
<div>
<Icon icon={Bell} />
</div>
Component.svelte
<script>
import Icon from "heroicons-for-svelte";
import { Bell as OutlineBell } from "heroicons-for-svelte/icons/outline";
import { Bell as SolidBell } from "heroicons-for-svelte/icons/solid";
</script>
<div>
<Icon icon={OutlineBell} />
<Icon icon={SolidBell} />
</div>
class or style:You can set the size of the icons by simply setting the font size of the Icon component.
The default size for the icons is 1em.
Component.svelte
<script>
import Icon from "heroicons-for-svelte"
import { Bell as OutlineBell } from "heroicons-for-svelte/icons/outline"
import { Bell as SolidBell } from "heroicons-for-svelte/icons/solid"
</script>
<Icon icon={OutlineBell} style="font-size: 24px"/>
<Icon icon={SolidBell} class="icon" />
<style>
:global(.icon) {
font-size: 3rem;
}
</style>
Try the package in this Svelte REPL
bell -> Bell or document-text -> DocumentText).npm run setupDevnpm run prepublishOnly to build the package