Getting Started - Svelte Ant Design Icons v1

GitHub Sponsor - shinokada NPM version of svelte-ant-design-icons github License NPM dw Downloads - svelte-ant-design-icons

Requirements #

- Svelte 4 or 5

Installation #

Install Svelte and Svelte Ant Design Icons:

npm create svelte@latest myapp
cd myapp
pnpm i -D svelte-ant-design-icons@v1-latest

Basic Usage #

In a svelte file:

<script>
  import { AccountBookFilled } from 'svelte-ant-design-icons';
</script>

<AccountBookFilled />

A11y friendly #

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

<AccountBookFilled
  title={{ id: 'my-title', title: 'Red accoutbook' }}
  desc={{ id: 'my-descrip', desc: 'The shape of a red accountbook' }}
  ariaLabel="red accountbook"
  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 AccountBookFilled from 'svelte-ant-design-icons/AccountBookFilled.svelte';
</script>

<AccountBookFilled />

Passing down other attributes #

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

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

Using svelte:component #

<svelte:component this={AccountBookFilled} />

Using onMount #

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

Import all #

Use import * as Icon from 'svelte-ant-design-icons.

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

<Icon.AccountBookFilled />

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