On this page

Flowbite Svelte Icons: v1

sponsor npm License npm

Requirements #

- Svelte 4 or 5 (without Runes)
- TailwindCSS
- tailwind-merge

Installation #

Install Svelte and TailwindCSS:

npm create svelte@latest my-project
cd my-project
npx svelte-add@latest tailwindcss
pnpm i
pnpm i -D flowbite-svelte-icons

To make sure the classes used by flowbite-svelte-icons are included by the Tailwindcss, add the following to tailwind.config.cjs.

const config = {
  content: [
       // more lines
        "./node_modules/flowbite-svelte-icons/**/*.{html,js,svelte,ts}",
    ],
    // more lines
}  

Basic Usages #

In a svelte file:

<script>
  import { AddressBookOutline } from 'flowbite-svelte-icons';
</script>

<AddressBookOutline />

A11y friendly #

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

<HeartSolid
  title={{ id: 'my-title', title: 'Red heart' }}
  desc={{ id: 'my-descrip', desc: 'The shape of a red heart' }}
  ariaLabel="red heart"
  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 AddressBookOutline from 'flowbite-svelte-icons/AddressBookOutline.svelte';
</script>

<AddressBookOutline />

Passing down other attributes #

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

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

Using svelte:component #

<script>
  import { AddressBookOutline } from 'flowbite-svelte-icons';
</script>

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

Using onMount #

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

Import all #

Use import * as Icon from 'flowbite-svelte-icons.

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

<Icon.AddressBookOutline />

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

<h1>Tailwind CSS</h1>
<Icon.AddressBookOutline class="text-blue-500" />