Getting Started - Svelte Awesome Icons v2

sponsor npm License npm

Requirements #

- Svelte 5:Runes

Installation #

Install Svelte:

// install Svelte 5
npm create svelte@latest my-project
cd my-project
pnpm i

Install svelte-awesome-icons v2:

pnpm i -D svelte-awesome-icons@next

Enable Runes in svelte.config.js:

import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: [vitePreprocess({})],
  compilerOptions: {
    runes: true
  },
  kit: {
    adapter: adapter()
  }
};

export default config;

Basic Usage #

In a svelte file:

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

<CalendarCheckRegular />

IDE support #

If you are using an LSP-compatible editor, such as VSCode, Atom, Sublime Text, or Neovim, hovering over a component name will display a documentation link, features, props, events, etc.

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 />

Asscessible SVGs #

A11y props, title, desc, and ariaLabel are used for accessible SVG icons.

Passing down other attributes #

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

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

Import all #

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

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

<Icon.CalendarCheckRegular />

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

<h2>Tailwind CSS</h2>
<Icon.CalendarCheckRegular class="text-blue-500" />