Core
@theme-kit/core
Vanilla JSRuntimeSSR-safe20 exports
The framework-agnostic heart of Theme Kit: store, model, registry, runtime, adapters, generation, validation and more.
Installation
Install the framework-agnostic core directly.
pnpm add @theme-kit/coreQuick Start
Complete copy-paste usage for this package.
1import { ThemeKit } from "@theme-kit/core/vanilla";
2
3const kit = new ThemeKit();
4kit.setMode("dark");
5kit.setFamily("plum");
6kit.toggleTheme();
7kit.update({ colors: { primary: "#07f" } });
8kit.use({ name: "brand", themes: customThemes });
9kit.toCSSVariables();
10kit.on("themeChange", (theme) => console.log(theme.name));
11kit.destroy();More Examples
Additional patterns for Core.
1import { generateTheme } from "@theme-kit/core";
2
3const { light, dark } = generateTheme({ seed: "#6366f1", family: "indigo" });
4
5// Validate a full theme against required tokens
6const result = validateTheme(dark, { themes: [light, dark] });
7// { valid: boolean, issues: [{ type, path, message }] }API Reference
Curated highlights below. The complete generated reference — every signature, parameter and type — is at /api-reference/core.
Store & Model
| Export | Description |
|---|---|
createThemeStore | Minimal reactive store — get / set / subscribe / batch / destroy. |
defineTheme | Type-safe, zero-cost theme definition helper. |
extendTheme / composeTheme | Inherit from a base theme and override, or merge multiple definitions. |
mergeThemeDefinitions / mergeTokens | Low-level merge utilities. |
resolveTheme | Resolve a theme definition, following `extends` chains. |
Registry
| Export | Description |
|---|---|
createThemeRegistry | Registry of every registered theme. |
register / registerMany / unregister / replace | Manage registered themes at runtime. |
getFamilies / getThemesByFamily | Query themes by family. |
Runtime
| Export | Description |
|---|---|
createThemeRuntime | Wires store, registry, selection, persistence, broadcast, DOM bindings, history, lifecycle and plugins. |
runtime.update(tokens) | Live theme editing — merge partial tokens into the active theme. |
runtime.use(pack) | Install a theme pack at runtime. |
runtime.history | Undo / redo / jump through full theme snapshots. |
runtime.snapshot / restore | Serialize and restore full runtime state. |
runtime.lifecycle | Typed event bus for theme changes. |
Tooling
| Export | Description |
|---|---|
generateTheme | Generate a complete light + dark pair from a seed color. |
validateTheme | Validate required semantic color tokens. |
migrateTheme / registerMigration | Version themes with a migration chain. |
getBuiltInThemes | Neutral, preset, brand and accessibility themes. |
flattenTokens / resolveTokens | Token resolution with references, expressions and derived colors. |
getContrastRatio / simulateCVD | Accessibility toolkit — WCAG contrast and color-vision-deficiency simulation. |