Skip to main content

Type Alias: CssVarMap<T>

CssVarMap<T> = { [K in keyof T as K extends `$${string}` ? never : K]: NonNullable<T[K]> extends string | number ? string : undefined extends T[K] ? CssVarMap<NonNullable<T[K]>> | undefined : CssVarMap<NonNullable<T[K]>> }

Defined in: roots/toVars.ts:28

Transforms a token-tree type into an identical structure where every leaf value becomes string (a CSS var(--tt-*) reference).

Keys starting with $ (e.g. $deprecated) are excluded — they are metadata, not consumable tokens.

Optional keys in the source type remain optional in the mapped type, so theme extensions such as dataviz? are typed as CssVarMap<...> | undefined and TypeScript will require callers to guard against undefined before accessing their members.

Type Parameters

Type Parameter
T

Example

type Colors = { action: { primary: { background: { default: TokenRef } } } };
type ColorVars = CssVarMap<Colors>;
// → { action: { primary: { background: { default: string } } } }