Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1870·nativewind

Bug: Color opacity modifiers (`/80`, `/50`, etc.) break and return `undefined` due to trailing `null` in `colorMix`

Author: rdsaini220Created Sep 24, 2026Updated Oct 1, 2026

Environment

  • NativeWind: 5.0.0-rc.0
  • react-native-css: 3.1.0-rc.0
  • Tailwind CSS: 4.3.0
  • React Native: 0.86.x / 0.76+

Description

When using color opacity modifier classes with CSS variables (e.g. text-text-inverse/80, bg-brand-primary/10, border-border/50), the styles completely fail to render any color (falling back to unstyled/black default).

Root Cause Analysis

  1. Compiler (parseColorMix in declarations.ts): Tailwind CSS v4 generates color-mix with only one percentage:
css
color: color-mix(in oklab, var(--color-text-inverse) 80%, transparent);

In react-native-css, parseColorMix constructs the argument array with 5 positional items:

return [
  {},
  "colorMix",
  [
    colorSpaceArg,
    leftColorArg,
    leftColorPercentage,
    rightColorArg,
    rightColorPercentage, // is undefined/null
  ],
];

Because rightColorPercentage is omitted, undefined (which becomes null after JSON serialization) is appended to the array: ['oklab', leftColor, '80%', 'transparent', null].

Runtime (colorMix in color-mix.ts):
const percentage = () => {
  const next = args[0];
  if (typeof next !== "string" || !next.endsWith("%")) return undefined;
  args.shift();
  return Number(next.slice(0, -1)) / 100;
};
let leftWeight = percentage(); // Shifts '80%'
const rightValue = args.shift(); // Shifts 'transparent'
let rightWeight = percentage(); // args[0] is null -> returns undefined WITHOUT shifting!
if (args.length) return; // <-- ABORTS HERE! args still contains [null]

Because args still contains [null], if (args.length) return; triggers and returns undefined, causing the property to have no color at all.

Suggested Fix
1. In src/compiler/declarations.ts:
Do not push undefined / null percentages into the argument array:

- return [{}, "colorMix", [colorSpaceArg, leftColorArg, leftColorPercentage, rightColorArg, rightColorPercentage]];
+ const colorMixArgs = [colorSpaceArg, leftColorArg];
+ if (leftColorPercentage !== undefined && leftColorPercentage !== null) {
+   colorMixArgs.push(leftColorPercentage);
+ }
+ colorMixArgs.push(rightColorArg);
+ if (rightColorPercentage !== undefined && rightColorPercentage !== null) {
+   colorMixArgs.push(rightColorPercentage);
+ }
+ return [{}, "colorMix", colorMixArgs];


2. In src/native/styles/functions/color-mix.ts:
Filter out nullish values in the runtime resolver defensively:

- const args: unknown[] = [...(resolved as unknown[])];
+ const args: unknown[] = (resolved as unknown[]).filter((arg) => arg !== null && arg !== undefined);

Source: nativewind/nativewind

View original on GitHubView discussion on GitHub