7.9.0 • Published 10 months ago

@indaco/svelte-iconoir v7.9.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

The entire iconoir set (1500+ SVG icons) as Svelte components.

See all available icons on the iconoir homepage.

Install

# npm
npm install @indaco/svelte-iconoir

# pnpm
pnpm add @indaco/svelte-iconoir

# yarn
yarn add @indaco/svelte-iconoir

Usage

<script>
	import { <ComponentName>Icon } from '@indaco/svelte-iconoir/<icon_variant>/<icon_name>';
</script>

where:

  • <ComponentName>: named as PascalCase variations of the icon name
  • <icon_variant>:
    • regular variant is the default one and does not need to be specified
    • solid (check on iconoir.com if available)
  • <icon_name>: the original icon name as per iconoir.com

Example

<script>
	import { SunLightIcon } from '@indaco/svelte-iconoir/sun-light';
	// or...
	import SunLightIcon from '@indaco/svelte-iconoir/components/SunLightIcon.svelte';

	// variant `solid`
	import { MinusCircleIcon } from '@indaco/svelte-iconoir/solid/minus-circle';
	// or component import
	import MinusCircleIcon from '@indaco/svelte-iconoir/components/solid/MinusCircleIcon.svelte';
</script>

Exceptions

The naming convention above has few exceptions breaking it:

  1. icons for companies (github, youtube etc.):
    • to reflect the real company names (GitHub, YouTube, etc.).
Icon NameComponent Name
githubGitHubIcon
github-circleGitHubCircleIcon
gitlab-fullGitLabFullIcon
linkedinLinkedInIcon
tiktokTikTokIcon
youtubeYouTubeIcon

Styling Icons

You can apply your own styles to the icon components in different ways:

1. Direct

<script>
	import { SunLightIcon } from '@indaco/svelte-iconoir/sun-light';
</script>

<SunLightIcon class="roundedColor" />

<style>
	.roundedColor {
		padding: 4px;
		background-color: yellow;
		border-style: solid;
		border-color: #d1d5db;
	}
</style>

2. Inline styles

<script>
	import { SunLightIcon } from '@indaco/svelte-iconoir/sun-light';
</script>

<SunLightIcon
	style="background-color: green; padding: 4px; border-radius: 9999px;"
	color="#ffffff"
/>

3. With Tailwind CSS

<script>
	import { SunLightIcon } from '@indaco/svelte-iconoir/sun-light';
</script>

<SunLightIcon class="p-1 rounded-full border-2 bg-green-400" size="xl" />

Properties

Each icon component can take any attribute of a normal SVG Element, for example:

<ZoomOutIcon fill="red" stroke-width="3" />

In addition to these, each component can take the following properties:

PropertyTypeDefaultDescription
sizeIconSizebaseSet the attributes width and height
altTextstringicon nameSet the aria-labelledby attribute on the svg

The underlying properties can also be set and overriden manually, e.g. setting width explicitly takes precedence over size.

/**
 * The size of the icon.
 * @typedef {(‘xs’|’sm’|’base’|’lg’|’xl’|number|string)} IconSize
 */
SizeValue
xs1em
sm1.25em
base1.5em
lg1.75em
xl2em

Event Forwarding

The following events are forwarded.

Name
on:click
on:dblclick
on:keyup
on:keydown
on:mouseenter
on:mouseleave

For example, you can set the on:click event on all icons.

<script>
	import { SunLightIcon } from '@indaco/svelte-iconoir/sun-light';
</script>

<SunLightIcon on:click="{()" =""> alert("hi!")} /></SunLightIcon>

Dev Flow

git clone https://github.com/indaco/svelte-iconoir.git

cd svelte-iconoir

# Install all dependencies
pnpm install # (or npm, yarn)

# Update Iconoir submodule
git submodule update --remote

# Generate Svelte components for each icon
pnpm generate:icons

# Package
pnpm build

## Run postbuild script
pnpm postbuild

License

Free and open-source software under the MIT License

7.9.0

10 months ago

7.1.0

1 year ago

7.8.0

11 months ago

7.6.0

1 year ago

7.0.0

2 years ago

7.4.0

1 year ago

7.7.0

1 year ago

7.5.0

1 year ago

6.1.0

2 years ago

4.7.2

2 years ago

4.7.1

2 years ago

4.6.0

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

6.0.1

2 years ago

6.0.0

2 years ago

6.0.3

2 years ago

6.0.2

2 years ago

4.5.0

2 years ago

4.7.0

2 years ago

4.4.0

2 years ago

4.3.1

2 years ago

4.3.0

2 years ago

4.1.0

2 years ago

4.0.0

2 years ago

4.2.0

2 years ago

4.1.1

2 years ago

3.3.1

2 years ago

3.3.0

2 years ago

3.2.0

2 years ago

3.1.0

3 years ago

2.6.1

3 years ago

2.6.0

3 years ago

2.6.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.5.0

3 years ago

2.5.1

3 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

1.1.1

4 years ago

1.1.2

4 years ago

2.0.3

4 years ago

2.1.1

4 years ago

2.0.2

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.6

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago