Svelte

kubai-icons-svelte provides each icon as a Svelte component. It requires Svelte 5.20 or later.

Install

bash
npm install kubai-icons-svelte

Usage

Import an icon by name and use it in a template:

svelte
<script>
  import { Folder, BellOff } from "kubai-icons-svelte";
</script>

<Folder size={28} color="#6366F1" />
<BellOff variant="soft" title="Muted" />

Props

Svelte icons use the same props as the React props table, with class for CSS classes. Toggle icons support active, defaultActive and onActiveChange.

svelte
<script>
  import { Bookmark } from "kubai-icons-svelte";
  let active = $state(false);
</script>

<Bookmark bind:active />

To decide whether a toggle goes through, bind a getter and a setter instead. The icon calls the setter on each toggle and only changes when the value does:

svelte
<script>
  import { Bookmark } from "kubai-icons-svelte";
  let active = $state(false);
  let locked = $state(false);
</script>

<Bookmark bind:active={() => active, (value) => { if (!locked) active = value; }} />

Styles and import paths

Import layered icons from the package root, two-tone icons from /duotone, and line icons from /line. Line icons also support strokeWidth.

svelte
<script>
  import { Folder } from "kubai-icons-svelte";
  import { Folder as TwoToneFolder } from "kubai-icons-svelte/duotone";
  import { Folder as LineFolder } from "kubai-icons-svelte/line";
</script>

<Folder />
<TwoToneFolder />
<LineFolder strokeWidth={1.75} variant="line-duo" />

Trigger from a parent

To play the motion when a whole button is hovered or receives keyboard focus, add data-kubai-trigger to the button and trigger="parent" to the icon:

svelte
<script>
  import { Trash } from "kubai-icons-svelte";
</script>

<button data-kubai-trigger>
  <Trash size={18} trigger="parent" />
  Delete
</button>

Icons by name

Append /dynamic to any style path for DynamicIcon. It renders an empty placeholder on the server and loads the icon in the browser.

svelte
<script>
  import { DynamicIcon } from "kubai-icons-svelte/dynamic";
  let { name } = $props();
</script>

<DynamicIcon {name} />

Server rendering

In SvelteKit, named icons render SVG on the server and attach hover motion in the browser. No client-only wrapper is needed.

Deep imports

Append /icons/<name> to any style path to import one icon as a default export:

js
import Folder from "kubai-icons-svelte/icons/folder";
import LineFolder from "kubai-icons-svelte/line/icons/folder";

The Svelte package was contributed by @smile-alive.