@icons-pack/svelte-simple-icons
TypeScript icon, indicating that this package has built-in type declarations

4.0.1 • Public • Published
svelte simple icons

svelte-simple-icons

This package provides the Simple Icons 13.21.0 packaged as a set of Svelte components.

www.npmjs.com! builds! downloads licence

Installation

Install the package in your project directory with:

// with yarn
yarn add @icons-pack/svelte-simple-icons

// with npm
npm add @icons-pack/svelte-simple-icons

Usage

All icons are imported from a single file, where [ICON SLUG] is replaced by a capitalized slug.

Demo

Edit codesandbox

Basic example

  <!-- Import a specific icon by its slug as: -->
  <!-- import { Si[ICON SLUG] } from 'simple-icons'; -->

  <script>
    import { SiReact, SiSvelte, SiDocker } from "@icons-pack/svelte-simple-icons";
  </script>

  <SiSvelte color="#FF3E00" size={90} />

  <SiReactJs color="#61DAFB" size={50} />

  <SiDocker />

Change title

  <!-- title default "Svelte" -->
  <script>
    import { SiSvelte } from "@icons-pack/svelte-simple-icons";
  </script>

  <SiSvelte title="My title" />

Custom styles

  <script>
    import { SiSvelte } from "@icons-pack/svelte-simple-icons";
  </script>

  <SiSvelte class="myStyle" />

  <style>
    .myStyle {
      width: 35px;
      height: 35px;
    }
  </style>

Type Definition for Dynamic Icons in Svelte Components

Sometimes, we want to provide the component dynamically to a component. We can do that by using svelte:component feature with the helper type SiComponentType type definition.

<script lang="ts">
  import type { SiComponentType } from '@icons-pack/svelte-simple-icons';

  export let icon: SiComponentType;
  export let text: string;
  export let click: () => void = () => console.log('do something');
</script>

<button on:click={click}>
  <svelte:component
    this={icon}
    title={text} <!-- optional, along with size and color properties --> 
  />
  {text}
</button>

<style lang="scss">
  button {
    display: flex;
    flex-direction: row;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.25s;
    box-shadow: none;
    text-shadow: none;
  }

  .icon {
    margin: 4px 4px 0 0;
  }
</style>

Faster Compilations

If you only need a few icons, you can import them individually instead of the entire file to improve compilation.

<script>
  import SiSvelte from "@icons-pack/svelte-simple-icons/icons/SiSvelte.svelte";
  import SiGithub from "@icons-pack/svelte-simple-icons/icons/SiGithub.svelte";
</script>

<SiGithub />
<SiSvelte />

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.0.133latest
4.0.0-rc.416rc

Version History

VersionDownloads (Last 7 Days)Published
4.0.133
4.0.0-rc.416
4.0.0-rc.30
4.0.0-rc.21
4.0.0-rc.10
4.0.0-rc.00
3.0.015
2.3.00
2.2.00
2.1.00
2.0.01
1.10.10
1.9.10
1.9.00
1.8.00
1.7.00
1.6.00
1.5.00
1.4.00
1.3.00
1.2.00
1.1.00
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i @icons-pack/svelte-simple-icons

Weekly Downloads

52

Version

4.0.1

License

MIT

Unpacked Size

14.5 MB

Total Files

9896

Last publish

Collaborators

  • wootsbot