css() for component styles, variants() for parameterized variants, globalCss() for resets and base styles, and font() + compileFonts() for font management.
css()
Define scoped style blocks. Returns an object with class name strings keyed by block name.Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
input | CSSInput | Object mapping block names to StyleBlock objects |
filePath | string | Used internally by the compiler for scoping |
Returns
CSSOutput<T> — object with each block name mapped to its scoped class name string, plus a non-enumerable css property containing the compiled CSS.
Style blocks
Each block value is aStyleBlock — an object of camelCase CSS properties. Numeric values get px auto-appended for length properties, or pass through raw for unitless properties (lineHeight, opacity, zIndex, etc.).
Nested selectors use & for pseudo-classes / child combinators and @ for at-rules:
Design tokens
Usetoken.* for theme-aware values (colors, spacing, radius, shadow, font). Tokens compile to CSS custom properties backed by your theme.
Type safety
CSS property names are validated against the full CSS property set. Typos produce TypeScript errors:variants()
Create a typed variant function for component styling with multiple visual states.Signature
VariantsConfig
| Property | Type | Description |
|---|---|---|
base | StyleBlock | Base styles applied to all variants |
variants | V | Object mapping variant names to option → StyleBlock maps |
defaultVariants | Partial<V> | Default variant selections when not specified |
compoundVariants | CompoundVariant<V>[] | Styles applied when specific variant combinations are active |
Returns
VariantFunction<V> — a callable function that accepts variant props and returns a class name string. Also has a .css property with the compiled CSS.
Compound variants
globalCss()
Define global styles — resets, base typography, body defaults. Properties use camelCase, converted to kebab-case in output.Nested at-rules
@keyframes, @media, and @supports accept a nested block — the inner
keys are frame selectors (from, to, 0%–100%) or regular selectors,
and their values are CSS declarations.
Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
input | GlobalCSSInput | Selector → block. Block is CSS declarations or (for at-rules) a map of nested selectors to declarations. |
Returns
GlobalCSSOutput — object with a css property containing the compiled CSS string.
font()
Create a font descriptor that describes a font family and its sources. Only woff2 format is supported.Parameters
| Parameter | Type | Description |
|---|---|---|
family | string | The font family name (e.g., 'DM Sans') |
options | FontOptions | Font configuration (see types below) |
Returns
FontDescriptor — a branded object describing the font, for use with compileFonts().
compileFonts()
Compile font descriptors into@font-face CSS, CSS custom properties, and preload link tags.
Parameters
| Parameter | Type | Description |
|---|---|---|
fonts | Record<string, FontDescriptor> | Map of token key to font descriptor. Keys must match [a-zA-Z0-9-]. |
Returns
CompiledFonts — object with fontFaceCss, cssVarsCss, cssVarLines, and preloadTags.