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 arrays of style entries |
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 entries
Each style entry in the array can be:| Type | Example | Description |
|---|---|---|
| Shorthand string | 'bg:white' | Utility shorthand expanded to CSS |
| Nested selector | { '&:hover': ['bg:gray.100'] } | Pseudo-classes, media queries, child selectors |
| CSS declaration | { 'grid-template': '1fr auto' } | Plain CSS property-value pair for arbitrary CSS |
Type-safe utility strings
Style entry strings are type-checked against theUtilityClass union type. Invalid utility class names produce TypeScript errors and editors provide autocomplete for valid options.
p, m, gap, etc.), color (bg), radius (rounded), shadow, alignment (items, justify), font weight (weight), line height (leading), content.
Multi-mode properties: text (font-size, text-align, or color), font (size or weight), border (width or color), ring (width or color), list (style or position).
Raw properties (any value accepted): cursor, transition, resize, opacity, inset, z, tracking, decoration, grid-cols, border-r/l/t/b, vt-name, view-transition-name, overflow, overflow-x, overflow-y.
Pseudo-prefixed: Validates the prefix (hover, focus, active, etc.) and property name. Example: 'hover:bg:primary.700'.
Color opacity modifier
Append/<opacity> (0–100) to any color token to apply alpha transparency using color-mix():
background-color: color-mix(in oklch, var(--color-primary) 50%, transparent)
Works with all color properties (bg, text, border) and multi-mode resolvers. Requires theme variables to be valid CSS color values (oklch, hsl, hex, etc.).
Fraction dimensions
UseN/M syntax for percentage-based sizing:
w, h, min-w, max-w, min-h, max-h). Fractions greater than 1 (e.g. w:3/2 → 150%) are allowed.
Transform scale keywords
Preset scale transform values:scale-0, scale-75, scale-90, scale-95, scale-100, scale-105, scale-110, scale-125, scale-150.
Overflow variants
Axis-specific overflow control:overflow-hidden keyword also remains available for backward compatibility.
The UtilityClass type is exported from @vertz/ui/css for use in custom type definitions.
variants()
Create a typed variant function for component styling with multiple visual states.Signature
VariantsConfig
| Property | Type | Description |
|---|---|---|
base | StyleEntry[] | Base styles applied to all variants |
variants | V | Object mapping variant names to their options (each option maps to style entries) |
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.Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
input | Record<string, Record<string, string>> | Object mapping selectors to CSS 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.