Icon colors, themes & dark mode
Each icon has gradients, outlines and marks, but you set only one accent color. Every other tone is calculated from it in CSS, so recoloring, theming and dark mode come down to setting that one color and, if you like, a variant.
The accent color
By default the accent is currentColor, the text color around the icon. Set it on the icon with the color prop, or with the CSS color property on the icon or any ancestor:
import { Folder, Leaf } from "kubai-icons-react";
<Folder color="#6366F1" />
<span style={{ color: "#14B8A6" }}>
<Leaf /> Sustainability
</span>Any CSS color works, including a theme variable such as color="var(--brand)". The tones are calculated with color-mix(), so a transition on color cross-fades every gradient:
.kubai-icon { transition: color .3s ease; }Badges
Badged icons, such as folder-plus or user-check, have a disc in one corner. It is dark gray with a white glyph by default. badgeColor sets the disc to any color, and badgeColor="semantic" picks one that suits each badge: green for add, red for remove, amber for warning.
import { FolderPlus } from "kubai-icons-react";
<FolderPlus /> {/* dark badge */}
<FolderPlus badgeColor="semantic" /> {/* green plus */}
<FolderPlus badgeColor="#7C3AED" />The color & soft variants
The default color variant uses saturated fills. soft uses lighter fills and darker outlines, and draws the white marks in a dark tone. Set it on one icon:
<Folder variant="soft" />Or set it once for a whole page or section. The variant is inherited like color, and the closest setting wins: the icon's own prop, then the nearest element, then the default.
import { Folder, VARIANTS } from "kubai-icons-react";
<body style={VARIANTS.soft}>
<Folder /> {/* soft */}
<Folder variant="color" /> {/* color */}
</body>In Vue, bind the same object with :style; in Solid, pass it to style. In Svelte or without a framework, call setVariant:
import { setVariant } from "kubai-icons/runtime";
setVariant(document.documentElement, "soft");Dark mode
Because the accent follows the text color, icons already change with your theme's text. When you want a specific accent in each theme, keep it in a CSS variable:
:root { --icon-accent: #2563EB; }
.dark { --icon-accent: #60A5FA; }<Folder color="var(--icon-accent)" />To switch the variant with the theme, call setVariant whenever the theme changes. This example follows the system setting; with a theme switch in your app, call it from there instead:
import { setVariant } from "kubai-icons/runtime";
const dark = matchMedia("(prefers-color-scheme: dark)");
const apply = () => setVariant(document.documentElement, dark.matches ? "soft" : "color");
apply();
dark.addEventListener("change", apply);The React, Vue, Svelte and Solid packages export setVariant too, so you don't need a separate import there.
Individual tones
For finer control, set these custom properties on an icon or any ancestor. Marks are the lines and symbols drawn on an icon.
| Property | Controls |
|---|---|
--ki-c | Base color for gradients and light marks. Default: currentColor. |
--ki-e | Base color for outlines and dark marks. Default: --ki-c. |
--ki-w | Color of the marks that are white by default. |
--ki-b | Color of the badge disc. Default: neutral dark gray. |
--ki-l | How far large solid fills fade to white toward the top, from 0% to 100%. |
The soft variant sets all of these except --ki-b.
Static files & downloads
Static SVG files have their colors written in. kubai-icons-static ships svg/ in the default blue (#5393FF) and svg-soft/ in the soft variant. For another color, request the icon by URL, or download it from the icon browser in a chosen color and variant:
<img src="https://icons.kubai.design/api/icon/folder.svg?color=EC4899&variant=soft" width="28" height="28" alt="" />Static files don't follow dark mode by themselves. Use a separate file per theme, for example with a <picture> element and a prefers-color-scheme media query.
Questions
Why does my icon look gray?
With no color set, the accent is currentColor, so the icon takes the text color around it. Set the color prop or a CSS color on the icon.
Can I give outlines a different color from the fills?
Yes. --ki-c is the base for fills and light marks, and --ki-e for outlines and dark marks. Set them separately on the icon or an ancestor.
Which variant should I use in dark mode?
Either works. Pick by how the icons read on your background, then switch with setVariant or a variant prop when the theme changes.
Do color changes re-render the icons?
No. Colors are CSS, so changing the color of a page of icons is a single style change.