Skip to main content
Vertz provides scoped, utility-driven styling with 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

ParameterTypeDescription
inputCSSInputObject mapping block names to StyleBlock objects
filePathstringUsed 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 a StyleBlock — 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

Use token.* 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:
Validation runs in both top-level and nested selector blocks.

variants()

Create a typed variant function for component styling with multiple visual states.

Signature

VariantsConfig

PropertyTypeDescription
baseStyleBlockBase styles applied to all variants
variantsVObject mapping variant names to option → StyleBlock maps
defaultVariantsPartial<V>Default variant selections when not specified
compoundVariantsCompoundVariant<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

ParameterTypeDescription
inputGlobalCSSInputSelector → 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

ParameterTypeDescription
familystringThe font family name (e.g., 'DM Sans')
optionsFontOptionsFont 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

ParameterTypeDescription
fontsRecord<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.

Types