Animated icons with Tailwind CSS

Kubai Icons need no Tailwind plugin or configuration. Every tone of an icon is calculated from one accent color, which defaults to currentColor, so the utility classes you already use for text also color the icons.

The examples use React. In Vue, Svelte and Solid, write class instead of className; with the web component, put the classes on <kubai-icon> or a parent.

Color

Set a text color class on the icon, or on any element around it:

tsx
import { Leaf, Bell } from "kubai-icons-react";

<Leaf className="text-emerald-500" />

<p className="text-amber-500">
  <Bell /> Reminders
</p>

Because the gradients, outlines and marks all derive from that one color, a single class changes the whole icon. The color prop does the same and takes precedence over inherited color.

Size

The size prop sets the width and height in pixels. Tailwind sizing classes work too, since CSS width and height override the SVG's own attributes:

tsx
<Folder size={20} />
<Folder className="size-5" />          {/* also 20px */}
<Folder className="size-6 md:size-8" /> {/* responsive */}

Dark mode

Pair the color with a dark: variant, as you would for text:

tsx
<Folder className="text-blue-600 dark:text-blue-400" />

To fade the color when the theme changes, add transition-colors. Transitions on color cross-fade every gradient in the icon.

tsx
<Folder className="text-blue-600 transition-colors dark:text-blue-400" />

For the soft variant across a whole theme, see Colors & dark mode.

Badge color & single tones

Icons read a few CSS custom properties, which Tailwind can set with arbitrary properties. For example, --ki-b is the color of the badge disc on badged icons:

tsx
import { FolderPlus } from "kubai-icons-react";

<FolderPlus className="text-sky-500 [--ki-b:#7C3AED]" />

The other properties are listed in Customization. For badges, the badgeColor prop is usually simpler: badgeColor="semantic" picks green for add, red for remove and so on.

Hover a group

Tailwind's group and group-hover: change styles, but they don't start an icon's motion. To play the motion when the group is hovered, add data-kubai-trigger to the same element and trigger="parent" to the icon:

tsx
import { Rocket } from "kubai-icons-react";

<a href="/launch" data-kubai-trigger className="group flex items-center gap-2 rounded-lg p-3 hover:bg-zinc-100">
  <Rocket className="size-6 text-zinc-500 group-hover:text-violet-600" trigger="parent" />
  Launch
</a>

Here the class changes the color on hover and the trigger plays the motion, so both happen together. More patterns are in Play an icon's animation when its button is hovered.

Static SVG files

Files from kubai-icons-static have their colors written in, so text color classes don't change them. Size them like any image. Each file has a margin for the drop shadow, so a 28px image matches a live icon at 24px:

html
<img src="https://cdn.jsdelivr.net/npm/kubai-icons-static@0/svg/folder.svg" class="size-7" alt="" />

Questions

Do I need to add the icons to Tailwind's content paths?

No. The icons don't use Tailwind classes, so Tailwind doesn't need to scan the package. Only the classes you write in your own files matter.

Can I use fill-* or stroke-* utilities?

They aren't the way to recolor these icons, because each icon's fills and outlines are calculated from its accent color. Use a text-* class or the color prop.

Does size-5 conflict with the size prop?

The class wins, because CSS overrides the width and height attributes that the size prop sets. Use one or the other.

Can I use my theme's CSS variables as the color?

Yes. Any CSS color works, including a variable such as text-(--brand) in Tailwind v4 or color="var(--brand)" on the icon.