generateSystem
generateSystem builds light and dark themes from one brand color. You get shade ramps, background and text pairs, and semantic colors for roles such as error and success. Your brand color stays exactly as given whenever it meets the contrast target, and text colors are chosen to pass contrast in both modes.
Example
import { generateSystem } from 'colore-js';
import { generateSystem as generateTheme } from 'colore-js/fn';
const system = generateSystem('#0f766e');
system.light.primaryBase.css(); // '#0f766e'
system.light.text.css(); // '#000000'
system.dark.text.css(); // '#ffffff'
system.audit().passed; // true
generateTheme('#0f766e').dark.background.css(); // '#070707'
Syntax
generateSystem<M extends readonly ThemeMode[] = readonly ['light', 'dark']>(
brand: ColorInput | Color,
config?: SystemConfig & { modes?: M }
): GeneratedSystem<M>
Parameters
Returns
Both exports return a generated system with the requested modes, resolved config, original seed, audit() and export methods. Each named mode has page tokens such as background and text. An omitted mode is undefined.
Throws
A ColorError for invalid colors or config. system.theme(mode) also throws if that mode was omitted.
Generate only a dark theme
import { generateSystem } from 'colore-js';
const darkOnly = generateSystem('#0f766e', { modes: ['dark'] });
darkOnly.dark.background.css(); // '#070707'
darkOnly.light; // undefined
You can audit the system before exporting it. The audit checks the role text pairs and page text tokens against the configured contrast target.
Related
- Generate a shadcn/ui theme from one color to export your variables
- Dark mode colors to check the generated pairs
- Theme generator to preview a system on UI examples in light and dark mode
- Theme exports for Tailwind v4, shadcn/ui and design tokens