toTailwindCss, toShadcnCss and toDTCG
Use the export methods on a system from generateSystem. Choose toTailwindCss() for @theme variables, toShadcnCss() for globals.css, or toDTCG() for a design-token document.
Example
import { generateSystem } from 'colore-js';
const system = generateSystem('#0f766e');
const tailwind = system.toTailwindCss({ format: 'hex' });
tailwind.includes('--color-primary-500: #0f766e;'); // true
tailwind.includes('.dark {'); // true
system.toDTCG().$schema;
// 'https://www.designtokens.org/schemas/2025.10/format.json'
Syntax
system.toTailwindCss(options?: SystemTailwindCssOptions): string
system.toShadcnCss(options?: ShadcnCssOptions): string
system.toDTCG(): DTCGDocument
Parameters
Returns
The two CSS methods return a stylesheet string. toDTCG returns a design-token document object with a schema and color tokens. Serialize it as JSON to write a token file.
Throws
A ColorError for unknown or unsupported CSS export options.
Prepare variables for shadcn/ui
import { generateSystem } from 'colore-js';
const system = generateSystem('#0f766e');
system.toShadcnCss().split('\n').find((line) => line.includes('--primary:'));
// ' --primary: oklch(0.511 0.086 186.391);'
The shadcn exporter checks its text pairs after formatting them. The check uses the system’s configured algorithm and target level.
Related
- Tailwind v4 colors from one brand color to add the CSS to a Tailwind project
- Generate a shadcn/ui theme for setup and verification
- generateSystem to choose theme modes and roles