Skip to content

color-mix(in oklch, …) resolves to no value on native (OKLCH not registered) #577

Open

Description

@tzptzptzptzptzp

Bug summary

On native, a runtime color-mix(in oklch, …) resolves to no value. src/native/styles/functions/color-mix.ts registers only sRGB, P3 and OKLab with colorjs.io, so ColorSpace.get("oklch") throws, the catch returns undefined, and the property is dropped without an error.

This affects any color-mix() that contains var() and uses in oklch, because those are resolved at runtime rather than by lightningcss. For example, a dark-mode token such as:

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131108;
    --fg: #f0ead6;
    --muted: color-mix(in oklch, var(--fg) 62%, var(--bg));
  }
}

renders .text-[--muted] with no visible colour.

Fix

Register OKLCH next to the other spaces:

-import { ColorSpace, to as convert, mix, OKLab, P3, parse, sRGB } from "colorjs.io/fn";
+import { ColorSpace, to as convert, mix, OKLab, OKLCH, P3, parse, sRGB } from "colorjs.io/fn";
 ColorSpace.register(sRGB);
 ColorSpace.register(P3);
 ColorSpace.register(OKLab);
+ColorSpace.register(OKLCH);

With this change, ["oklch", "#f0ead6", "62%", "#131108"] resolves to about rgba(147, 143, 127, 1), which matches the browser. We are applying this fix locally with patch-package. It might be worth registering the other spaces that color-mix() accepts as well (lab, lch, hsl, hwb, xyz, …), since any unregistered space fails the same way.

Library version

3.1.0-rc.0. 3.1.0-rc.1 has the same color-mix.ts.

Environment info

expo: SDK 58
nativewind: 5.0.0-rc.0
react-native-css: 3.1.0-rc.0
colorjs.io: 0.7.0
iOS simulator (iOS 27.2)

Related: #481 (a different bug in the same function: a null weight slot).

Activity

  1. tzptzptzptzptzp commented on Nov 19, 2026

    @tzptzptzptzptzp
    Author

    I missed it when filing this: #457 already fixes this. It registers OKLCH (along with HSL, Lab and LCH) and also handles the omitted-weight case from #481.

    In our app (Expo SDK 58, nativewind 5.0.0-rc.0, react-native-css 3.1.0-rc.0, iOS simulator), registering OKLCH and filtering the null weight slot made every runtime color-mix(in oklch, …) resolve to the browser's values. #457 makes the same change.

  2. sammoore commented on Nov 21, 2026

    @sammoore
    Contributor

    @tzptzptzptzptzp #457 looks okay, but need to double-check the args and parseWeights change.

    Although current aim is the remaining Nativewind v4 regressions (only 1 remains AFAICT), this is high value and low risk; I'll aim to get it in the next RC, expected in the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions