Skip to content

Core

@theme-kit/core

Vanilla JSRuntimeSSR-safe20 exports

The framework-agnostic heart of Theme Kit: store, model, registry, runtime, adapters, generation, validation and more.

Install the framework-agnostic core directly.

bash
pnpm add @theme-kit/core

Quick Start

Complete copy-paste usage for this package.

vanilla.ts
ts
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.

generate.ts
ts
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

ExportDescription
createThemeStoreMinimal reactive store — get / set / subscribe / batch / destroy.
defineThemeType-safe, zero-cost theme definition helper.
extendTheme / composeThemeInherit from a base theme and override, or merge multiple definitions.
mergeThemeDefinitions / mergeTokensLow-level merge utilities.
resolveThemeResolve a theme definition, following `extends` chains.

Registry

ExportDescription
createThemeRegistryRegistry of every registered theme.
register / registerMany / unregister / replaceManage registered themes at runtime.
getFamilies / getThemesByFamilyQuery themes by family.

Runtime

ExportDescription
createThemeRuntimeWires 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.historyUndo / redo / jump through full theme snapshots.
runtime.snapshot / restoreSerialize and restore full runtime state.
runtime.lifecycleTyped event bus for theme changes.

Tooling

ExportDescription
generateThemeGenerate a complete light + dark pair from a seed color.
validateThemeValidate required semantic color tokens.
migrateTheme / registerMigrationVersion themes with a migration chain.
getBuiltInThemesNeutral, preset, brand and accessibility themes.
flattenTokens / resolveTokensToken resolution with references, expressions and derived colors.
getContrastRatio / simulateCVDAccessibility toolkit — WCAG contrast and color-vision-deficiency simulation.
@theme-kit/core — Theme Kit