Svelte Awesome Icons: v1

sponsor npm License npm

Requirements #

You need to use the following:

- Svelte 4 or 5 (without Runes)

Installation #

Install Svelte and TailwindCSS:

npm create svelte@latest my-project
cd my-project
pnpm i -D svelte-awesome-icons

Basic Usage #

In a svelte file:

<script>
  import { CalendarCheckRegular } from 'svelte-awesome-icons';
</script>

<CalendarCheckRegular />

A11y friendly #

Use `title`, `desc`, and `ariaLabel` props to make your icons accessible.

<AddressBookOutline
  title={{ id: 'my-title', title: 'Red addressbook' }}
  desc={{ id: 'my-descrip', desc: 'The shape of a addressbook with red color' }}
  ariaLabel="red addressbook"
  color="red"
/>

Faster compiling #

If you need only a few icons from this library in your Svelte app, import them directly. This can optimize compilation speed and improve performance by reducing the amount of code processed during compilation.

<script>
  import CalendarCheckRegular from 'svelte-awesome-icons/CalendarCheckRegular.svelte';
</script>

<CalendarCheckRegular />

Passing down other attributes #

Since all icons have ...$$restProps, you can pass other attibutes as well.

<CalendarCheckRegular id="my-svg" transform="rotate(45)" />

Using svelte:component #

<script>
  import { CalendarCheckRegular } from 'svelte-awesome-icons';
</script>

<svelte:component this="{CalendarCheckRegular}" />

Using onMount #

<script>
  import { CalendarCheckRegular } from 'svelte-awesome-icons';
  import { onMount } from 'svelte';
  const props = {
    size: '50',
    color: '#ff0000'
  };
  onMount(() => {
    const icon = new CalendarCheckRegular({ target: document.body, props });
  });
</script>

Import all #

Use `import * as Icon from 'svelte-awesome-icons`.

<script>
  import * as Icon from 'svelte-awesome-icons';
</script>

<Icon.CalendarCheckRegular />

<h1>Size</h1>
<Icon.CalendarCheckRegular size="30" />