Props - Svelte Ant Design Icons v2

Props #

All icons are extended SVGAttributes from svelte/elements.

- size = ctx.size || '24'
- role = ctx.role || 'img'
- color = ctx.color || 'currentColor'
- title = {}
- desc = {}
- ariaLabel = <icon file name>
- class, id, name, role, and all other props from SVGAttributes

Types #

import type { SVGAttributes } from 'svelte/elements';

type TitleType = {
  id?: string;
  title?: string;
};

type DescType = {
  id?: string;
  desc?: string;
};

interface BaseProps extends SVGAttributes<SVGElement>{
  size?: string;
  role?: string;
  color?: string;
}

interface CtxType extends BaseProps {}

interface Props extends BaseProps{
  title?: TitleType;
  desc?: DescType;
  ariaLabel?: string;
}

Size #

To change the size of an icon, use the size prop and specify the desired size. For example:

<AppstoreAddOutlined size="40" />

You can add a custom size using Tailwind CSS by including the desired classes in the class prop. For example:

<AppstoreAddOutlined class="h-24 w-24 text-blue-700 mr-4" />

CSS HEX Colors #

Use the color attribute to change colors with HEX color code:

<AppstoreAddOutlined color="#ff0000" />

CSS framework #

You can apply CSS framework color and other attributes directly to the icon component or its parent tag using the class prop.

Tailwind CSS #

<AppstoreAddOutlined size="30" class="text-red-700 dark:text-green-300 inline m-1" />

<div class="text-red-700 dark:text-green-300 inline m-1">
  <AppstoreAddOutlined size="30" />
</div>

Bootstrap #

<AppstoreAddOutlined class="position-absolute top-0 px-1" />

Dark mode #

Your website with Tailwind CSS, add your dark mode class to the class prop.

<AppstoreAddOutlined class="text-blue-700 dark:text-red-500" />

A11y #

All icons have aria-label. For example AddressBookSolid has aria-label="addressbook solid". Use ariaLabel prop to modify the aria-label value.

<AppstoreAddOutlined ariaLabel="address card outline" />

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

<AppstoreAddOutlined
  title={{ id: 'my-title', title: 'Red app store icon' }}
  desc={{ id: 'my-descrip', desc: 'The shape of three squares and a plus.' }}
  ariaLabel="red app store icon"
  color="red"
/>
Red heartThe shape of a red heart

Passing down other attributes #

As default all icons are extended SVGAttributes SVGElement interface. This means you can add any standard SVG attribute or event listener to our icon components.

<AppstoreAddOutlined
  id="my-svg"
  transform="rotate(45)"
  class="hover:cursor-pointer dark:text-white"
  onclick={() => alert('hello')} 
/>