Resolve theme configuration
Validate a minimal config, apply preset defaults, and produce the exact configuration used by token generation.
Require one light primary color
color.light.primary is the only required theme value. UI Core derives a secondary anchor when it is omitted and produces a dark mode when no complete dark palette is supplied.
tsimport type { TavoUiThemeConfig } from "@tavojs/ui-core";
const config: TavoUiThemeConfig = {
color: { light: { primary: "#116a67" } }
};Apply configuration in a predictable order
resolveThemeConfig starts from internal defaults, applies the chosen preset, then deeply merges explicit project values. A preset is a starting point, never a lock on the final design.
tsimport { resolveThemeConfig } from "@tavojs/ui-core";
const resolved = resolveThemeConfig({
preset: "enterprise",
color: { light: { primary: "#7c5cff" } },
scale: { density: "spacious", shadow: 0.2 }
});Here the enterprise preset supplies unspecified values, while spacious density and the explicit shadow override its scale choices.
Fail close to the configuration error
Use the published schema for editor validation when configuration lives in JSON.
Keep numeric scale values within documented ranges.
Use supported preset, method, mode, density, and contrast names.
Validate output selectors and token records before emitting platform files.
Run resolution in CI so invalid theme changes fail before package or app builds.