Navigated to /docs/ui-core/config

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. Brand and semantic color inputs must be hex strings such as #06c or #0066cc, not CSS variables or named colors.

TS
tsimport type { TavoUiThemeConfig } from "@tavojs/ui-core";

const config: TavoUiThemeConfig = {
  color: { light: { primary: "#116a67" } }
};

Apply configuration in a predictable order

resolveThemeConfig merges explicit project values over a selected preset. Without a preset, it returns the input config. This helper does not fill every default or validate a complete theme; call buildThemeTokens for validation and generated values.

TS
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.