Skip to content

theme/css-vars

import { … } from 'zidane-ui'ui/src/theme/css-vars.ts

Functions#

contrastToCssVarsFunction#

Contrast control → the three variables the CSS contrast layer consumes.

level 100 → identity. level <100 → text is faded toward the background (base < 100%). level >100 → text is pushed toward pure white / black (boost > 0%).

Borders take a quarter of the boost so raising contrast sharpens text without turning every hairline into a wall.

TypeScript
function contrastToCssVars(level: number, appearance: Appearance): CssVarMap
Parameters
NameTypeDescription
levelnumber

The contrast setting in percent, clamped to 50..200. 100 changes nothing.

appearanceAppearance

The palette appearance, which picks white or black as the target text is pushed toward.

ui/src/theme/css-vars.ts:151

depthToCssVarsFunction#

Contrast → depth. Past 150 the surfaces go FLAT: no light, no shadows, hairlines at full border strength, so separation is all line and no atmosphere. Below 100 the ladder compresses toward the canvas along with the text (--zg-depth-mix).

TypeScript
function depthToCssVars(level: number, surfaces: SurfaceLadder): CssVarMap
Parameters
NameTypeDescription
levelnumber

The contrast setting in percent, clamped to 50..200. Above 150 the surfaces go flat.

surfacesSurfaceLadder

The surface ladder to take the shadows and sheen from.

ui/src/theme/css-vars.ts:174

paletteToCssVarsFunction#

Turns a resolved palette into --zg-* custom properties: surfaces, lines, text, accent, status colours, dots, sphere, depth inputs, diff and chip colours. Pure, with no DOM.

TypeScript
function paletteToCssVars(p: ResolvedPalette): CssVarMap
Parameters
NameTypeDescription
pResolvedPalette

The resolved palette.

CssVarMap

The custom properties to write onto :root or into a stylesheet.

ui/src/theme/css-vars.ts:47

Types#

CssVarMapType#

A map of --zg-* custom property names to their CSS values.

TypeScript
type CssVarMap = Record<`--zg-${string}`, string>

ui/src/theme/css-vars.ts:38