@three-forma-styli/core
v0.1.3
Published
Core design token generation library - framework-agnostic, browser and Node.js compatible
Maintainers
Readme
@three-forma-styli/core
Core library for generating design tokens as CSS custom properties.
Installation
npm install @three-forma-styli/coreUsage
import { generate, toCss, oklch } from '@three-forma-styli/core';
import type { DesignSystem, PartialDesignSystem } from '@three-forma-styli/core';
// Full design system
const system: DesignSystem = {
colors: { /* ... */ },
spacing: { /* ... */ },
gap: { /* ... */ },
typography: { /* ... */ },
border: { /* ... */ },
time: { /* ... */ }
};
const css = toCss(generate(system));
// Partial generation (e.g., just colors)
const partial: PartialDesignSystem = {
colors: { /* ... */ }
};
const colorsCss = toCss(generate(partial));API
generate(designSystem, config?)- Generate intermediate representation from design systemtoCss(ir, config?)- Transform IR to CSS stringoklch(l, c, h)- Create OKLCH color objectgenerateCss(designSystem, config?)- Convenience function combining generate + toCss
Types
DesignSystem- Full design system with all token familiesPartialDesignSystem- Partial design system (all families optional)GeneratorConfig- Configuration for token generationCssTransformerConfig- Configuration for CSS output
See the main repo for full documentation.
