@udixio/theme

@udixio/theme is the low-level engine that powers all Udixio theming. Most developers never need it directly — @udixio/ui-react wraps it and handles everything through defineConfig and ThemeProvider.

Use @udixio/theme when you need to:

  • Generate theme CSS outside of React (Vite plugin, Node script, build step)
  • Create a custom palette derivation algorithm (custom variant)
  • Build a custom plugin that reads computed color tokens
  • Access the raw HCT values of any semantic color token

Package responsibilities

PackageResponsibility
@udixio/themeCore engine — loader(), variant(), Hct, Palette, Color, plugin base classes
@udixio/tailwindTailwindPlugin — generates Tailwind CSS from tokens — and defineConfig, which auto-wires it alongside FontPlugin
@udixio/ui-reactThemeProvider — React runtime layer; re-exports defineConfig for convenience
@udixio/ui-angularAngular components. Theming goes through @udixio/tailwind directly — there is no Angular runtime layer

Architecture

The core is a dependency-injection container (bootstrap()) that assembles four modules:

plaintext
Context      — holds sourceColor, isDark, contrastLevel, variant
PaletteApi   — derives hue+chroma palettes from Context
ColorApi     — resolves semantic tokens (primary, surface…) from Palette tones
PluginApi    — executes plugins in order, each reading from ColorApi

Everything is re-evaluated top-down on every api.load() call.

loader()

The main entry point for headless usage:

ts
import { loader } from '@udixio/theme';

const api = await loader(config, load);
  • config — same ConfigInterface used by defineConfig, minus fontFamily/fontStyles
  • load — boolean, default true — pass false to initialize without running the first load

See Using loader() for full usage examples.

Advanced pages

PageWhat you’ll learn
Using loader()Headless usage, Node/Vite integration, api.context.update()
Variants APIvariant() function, custom palette derivation
Palettes APIapi.palettes.get(), sync(), PaletteCallback
Colors APIapi.colors.get(), FromPaletteOptions, contrastCurve
Plugin systemPluginAbstract, PluginImplAbstract, custom plugins