Skip to main content

Type Alias: CssVarsMap<T>

CssVarsMap<T> = { [K in keyof T as K extends `$${string}` ? never : K]: NonNullable<T[K]> extends string | number ? string : undefined extends T[K] ? CssVarsMap<NonNullable<T[K]>> | undefined : CssVarsMap<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 CssVarsMap<...> | 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 = CssVarsMap<Colors>;
// → { action: { primary: { background: { default: string } } } }