Theme
@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
| Package | Responsibility |
|---|---|
@udixio/theme | Core engine — loader(), variant(), Hct, Palette, Color, 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; re-exports defineConfig for convenience |
@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 ColorApiEverything 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— sameConfigInterfaceused bydefineConfig, minusfontFamily/fontStylesload— 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(), FromPaletteOptions, contrastCurve |
| Plugin system | PluginAbstract, PluginImplAbstract, custom plugins |