@udixio/theme
@udixio/theme is the low-level engine that powers all Udixio theming. Most developers use defineConfig from @udixio/tailwind and the runtime adapter appropriate to their framework, such as ThemeProvider from @udixio/ui-react.
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
| Package | Responsibility |
|---|---|
@udixio/theme | Core engine — loader(), variant(), Color, Palette, the tone adjusters, plugin base classes |
@udixio/tailwind | TailwindPlugin — generates Tailwind CSS from tokens — and defineConfig, which auto-wires it alongside FontPlugin |
@udixio/ui-react | ThemeProvider — React runtime layer |
@udixio/ui-angular | Angular 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 ColorApiContext-dependent palettes and colors are refreshed when their dependencies change; plugins consume the current values when api.load() runs. Most Color values therefore remain lazy until a property such as hex or tone is read.
loader()
The main entry point for headless usage:
ts
import { loader } from '@udixio/theme';
const api = await loader(config, load);config— the core@udixio/themeConfigInterface; unlikedefineConfig, it does not accept the flat Tailwind or typography optionsload— boolean, defaulttrue— passfalseto initialize without running the first load
See Using loader() for full usage examples.
Advanced pages
| Page | What you’ll learn |
|---|---|
| Using loader() | Headless usage, Node/Vite integration, api.context.update() |
| Variants API | variant() function, custom palette derivation |
| Palettes API | api.palettes.get(), sync(), PaletteCallback |
| Colors API | api.colors.get(), Color.fromPalette(), contrastCurve |
| Plugin system | PluginAbstract, PluginImplAbstract, custom plugins |