Animated icons without a build step
The <kubai-icon> web component brings every icon to any page with one script tag. It needs no bundler and no install, and it works in plain HTML, CMS pages and frameworks that render custom elements.
Plain HTML
Load the component once, in the <head> or anywhere before the icons. Then write one element per icon:
<script type="module" src="https://cdn.jsdelivr.net/npm/kubai-icons@0/dist/cdn/element.js"></script>
<kubai-icon name="folder"></kubai-icon>
<kubai-icon name="bell-off" size="32" color="#F97316" variant="soft" label="Muted"></kubai-icon>The script loads each icon's file from the same CDN the first time that icon is used, so a page downloads only the icons it shows. The element reserves its size before the icon arrives, so the layout doesn't shift.
Attributes
| Attribute | Default | Description |
|---|---|---|
name | None | The icon's kebab-case name, such as folder-plus. An unknown name renders nothing. |
size | 24 | Width and height in pixels. |
color | currentColor | The accent color that every tone is calculated from. |
variant | color | soft uses lighter fills and darker outlines. |
badge-color | dark gray | Color of the badge disc, or semantic. |
trigger | hover | hover, parent or none. See below. |
label | None | Accessible name. Without it, screen readers skip the icon. |
Changing an attribute later, for example from your own script, redraws the icon.
Play the motion when a link or button is hovered
Add data-kubai-trigger to the link or button and trigger="parent" to the icon. Without the attribute, the icon listens to its direct parent.
<a href="/downloads" data-kubai-trigger>
<kubai-icon name="download" size="18" trigger="parent"></kubai-icon>
Downloads
</a>WordPress & other CMSs
In the WordPress block editor, add a Custom HTML block and paste the script tag and the icons into it. If you use icons on many pages, add the script tag once to the site's header instead, through your theme or a plugin that inserts code into the head, and use only the <kubai-icon> elements in your blocks. The same approach works in any CMS or site builder that accepts custom HTML.
<script type="module" src="https://cdn.jsdelivr.net/npm/kubai-icons@0/dist/cdn/element.js"></script>
<p style="color: #14B8A6">
<kubai-icon name="leaf" size="28"></kubai-icon>
Grown without pesticides
</p>Svelte & SvelteKit
In a Svelte 5 app with a build step, use the Svelte package instead: it renders icons on the server and takes props. Without a build step, add the script tag to src/app.html in SvelteKit, or to index.html in a Vite app. Svelte renders custom elements as they are, and attributes can be bound:
<script>
let { icon = "folder" } = $props();
</script>
<kubai-icon name={icon} size="24"></kubai-icon>Solid
For Solid 1.9 and later, use the Solid package, which renders on the server and takes props. Solid 2 has no package yet: there the icons come from this web component until the package moves to Solid 2. It plays the same motion and takes the same attributes, but your app's state can't drive it (there are no active or hover props, and an icon a tap toggles keeps that state inside the element), it isn't rendered on the server, and it loads each icon the first time the page shows it.
Add the script tag to index.html. Solid renders custom elements as they are, and static attributes such as size="24" work in any version. Binding an attribute to a signal depends on the version. In Solid 1, write attr:name: a plain name={...} sets a DOM property, which the element ignores. In Solid 2, attributes are the default, so write name={...}.
import { createSignal } from "solid-js";
const [icon, setIcon] = createSignal("inbox");
// Solid 1
<kubai-icon attr:name={icon()} size="24"></kubai-icon>
// Solid 2
<kubai-icon name={icon()} size="24"></kubai-icon>With TypeScript, declare the element once, for example in src/kubai-icon.d.ts. For Solid 2, write @solidjs/web instead of solid-js in both places and leave out the attr:name line.
import "solid-js";
declare module "solid-js" {
namespace JSX {
interface IntrinsicElements {
"kubai-icon": JSX.HTMLAttributes<HTMLElement> & {
name?: string;
size?: number | string;
color?: string;
variant?: "color" | "soft";
"badge-color"?: string;
trigger?: "hover" | "parent" | "none";
label?: string;
"attr:name"?: string;
};
}
}
}Angular
Add the script tag to src/index.html. Angular rejects unknown elements unless the component allows them, so add CUSTOM_ELEMENTS_SCHEMA:
import { Component, CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
@Component({
selector: "app-toolbar",
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<button data-kubai-trigger>
<kubai-icon name="settings" size="18" trigger="parent"></kubai-icon>
Settings
</button>
<kubai-icon [attr.name]="iconName"></kubai-icon>
`,
})
export class ToolbarComponent {
iconName = "inbox";
}Use [attr.name] to bind an attribute from a component property.
Astro
Add the script tag to your layout's <head> with is:inline, so Astro leaves it as it is, then use the element in any page or component:
---
// src/layouts/Base.astro
---
<html lang="en">
<head>
<script is:inline type="module" src="https://cdn.jsdelivr.net/npm/kubai-icons@0/dist/cdn/element.js"></script>
</head>
<body>
<kubai-icon name="rocket" size="32"></kubai-icon>
<slot />
</body>
</html>Images without any script
Where scripts aren't allowed, such as a README or a Markdown page, use a static SVG file in an <img> tag. It has no motion. See Static SVG.
<img src="https://icons.kubai.design/api/icon/folder.svg?color=EC4899" width="28" height="28" alt="" />Questions
Which version does the CDN script load?
A URL with @0 loads the latest 0.x release, so new icons become available without changing the page. The CDN can take a while to switch to a new release. Pin an exact version, such as kubai-icons@0.16.0, to keep a page unchanged.
Does the web component work with React, Vue, Svelte or Solid?
It does, but the kubai-icons-react, kubai-icons-vue, kubai-icons-svelte and kubai-icons-solid packages are a better fit there: they render on the server and take props.
How do I find an icon's name?
Open the icon browser and search by word or meaning. Each icon's panel shows its kebab-case name, such as calendar-check.
Is the motion accessible?
Keyboard focus plays the motion as hover does, a tap plays it on touch screens, and prefers-reduced-motion skips the animation.