Skip to content

parseColor

parseColor(props): ColorValue | null

Defined in: packages/core/src/fields/color/convert.ts:348

Parses a stored colour value into a ColorValue.

Accepts every notation serializeColor can emit, regardless of the field’s current format — so a field whose format changed still reads its stored colour instead of resetting. Values with no literal colour (var(--token), the empty string) return null.

Input props.

string

The stored field value.

ColorValue | null

The parsed colour, or null when the value is empty, a theme-token reference, or not a recognised notation.

parseColor({ value: "oklch(65.7% 0.1793 40.9)" }) // { r: 232, g: 98, b: 42, a: 1 }
parseColor({ value: "var(--primary)" }) // null