Skip to content

feat: add inset shadow parsing support#277

Open
YevheniiKotyrlo wants to merge 1 commit intonativewind:mainfrom
YevheniiKotyrlo:fix/tailwind-v4-shadow-support
Open

feat: add inset shadow parsing support#277
YevheniiKotyrlo wants to merge 1 commit intonativewind:mainfrom
YevheniiKotyrlo:fix/tailwind-v4-shadow-support

Conversation

@YevheniiKotyrlo
Copy link

@YevheniiKotyrlo YevheniiKotyrlo commented Jan 11, 2026

Problem

Tailwind CSS v4 shadow and ring utilities don't work on React Native. Two root causes:

  1. Inset shadows — The box-shadow shorthand handler doesn't recognize the inset keyword, so shadows arriving through CSS variables at runtime fail to parse. (Fixed here)
  2. Missing @property defaults — Tailwind v4's @property declarations aren't parsed, so variables like --tw-ring-shadow have no initial values. (Fixed in feat: add CSS @property rule support #284, stacked on this PR)

This is PR 1/2. PR #284 builds directly on this branch.

Changes

src/native/styles/shorthands/box-shadow.ts

  • Implemented inset field descriptor with literal string matching
  • Added 4 inset shorthand patterns: with/without spread, with/without color, color-first
  • Added normalizeInsetValue() to convert string "inset" to boolean true for React Native's boxShadow prop

src/__tests__/native/box-shadow.test.tsx

  • 4 compile-time tests: basic inset, color-first, inherited color, mixed inset+regular
  • 2 runtime tests: inset via CSS variable, inset via CSS variable without explicit spread
  • 1 CSS variable resolution test with strict assertions

Review notes

  • Per review feedback, all Tailwind-specific root variable defaults were removed from this PR — those are handled generically via @property support in feat: add CSS @property rule support #284
  • All tests use toStrictEqual with exact expected values
  • Two files changed, +192/−3 lines

@danstepanov danstepanov force-pushed the fix/tailwind-v4-shadow-support branch from aee4d5d to 4cbd812 Compare February 24, 2026 07:43
@danstepanov danstepanov self-requested a review February 24, 2026 07:51
Copy link
Member

@danstepanov danstepanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. The inset shadow parsing is solid. I have concerns about one part though.

  1. Inset shadow parsing (box-shadow.ts) looks good. The new shorthand patterns and normalizeInsetValue correctly handle inset shadows coming through CSS variables at runtime. Statically-written inset shadows are already handled at compile time by lightningcss and the compiler, so this specifically covers the runtime/variable path, which is what matters for Tailwind's generated output. Minor gap: [inset, offsetX, offsetY, blurRadius, color] isn't covered, though Tailwind doesn't generate that pattern so not a blocker.

  2. Root variable defaults (root.ts) needs to move. Hardcoding --tw-shadow, --tw-inset-shadow, --tw-ring-shadow, etc. in react-native-css couples the generic CSS engine to Tailwind's internal variable names. react-native-css is framework-agnostic and shouldn't have knowledge of Tailwind-specific variables. These defaults belong in nativewind (e.g., in nativewind/theme.css as :root variable declarations). That keeps the separation clean. The architectural intention of v5 is that Nativewind adapts Tailwind for RN while react-native-css handles generic CSS.

Also, rootVariables("tw-shadow-color").set([["initial"]]) seems problematic. What does "initial" resolve to at runtime? It's not a value react-native-css knows how to interpret.

  1. The inset shadow tests are good. The "Tailwind v4 shadow variables" test should assert more than .toBeDefined(). Since #0000 shadows get filtered by omitTransparentShadows, the test should verify what the resulting array actually contains.

TLDR: Could you split this into two PRs? The inset shadow changes to box-shadow.ts and tests are ready to merge. The root variable defaults need to move to nativewind.

@YevheniiKotyrlo YevheniiKotyrlo force-pushed the fix/tailwind-v4-shadow-support branch from 4cbd812 to aba4514 Compare February 24, 2026 11:54
@YevheniiKotyrlo YevheniiKotyrlo changed the title feat: add Tailwind CSS v4 shadow support and inset shadows feat: add inset shadow parsing support Feb 24, 2026
@YevheniiKotyrlo
Copy link
Author

Thanks for the review.

Addressed all three points:

  1. Root variable defaults removed — the root.ts changes have been removed from this PR. Instead of hardcoding Tailwind-specific defaults, I've implemented generic CSS @property support in feat: add CSS @property rule support #284. This parses @property rules with initial-value and stores them as root variables (vr), keeping react-native-css framework-agnostic.

  2. -moz-orient hack removed — since @property handles defaults natively, the @supports fallback is no longer needed. Removed in feat: add CSS @property rule support #284.

  3. Tests strengthenedfeat: add CSS @property rule support #284 includes tests with exact value assertions (toStrictEqual) instead of .toBeDefined(). Also added a separate nativewind PR (test: add shadow and ring utility validation tests nativewind#1717) with end-to-end shadow/ring validation tests covering shadow-sm, shadow-md, shadow-lg, ring-2, ring-0, and shadow-sm ring-2 composition.

This PR (inset shadow parsing) is ready for re-review — it now only contains the box-shadow.ts shorthand patterns and normalizeInsetValue, plus the inset-specific tests.

@YevheniiKotyrlo YevheniiKotyrlo force-pushed the fix/tailwind-v4-shadow-support branch 2 times, most recently from 5f1cf77 to a42e31f Compare February 25, 2026 21:05
@YevheniiKotyrlo
Copy link
Author

@danstepanov Just checking in — this PR now only contains the box-shadow.ts inset shorthand patterns and normalizeInsetValue, plus the inset-specific tests. All the root variable/Tailwind-specific changes have been moved to #284 (CSS @property support) as requested.

The minor gap you noted ([inset, offsetX, offsetY, blurRadius, color]) has also been added.

Ready for re-review whenever you get a chance.

@danstepanov
Copy link
Member

hey @YevheniiKotyrlo thanks for updating, i'll review this again in the coming days, i'm focused on knocking out some issues in Nativewind v4 atm

@YevheniiKotyrlo YevheniiKotyrlo force-pushed the fix/tailwind-v4-shadow-support branch from a42e31f to a3cba9e Compare March 3, 2026 10:37
@YevheniiKotyrlo YevheniiKotyrlo force-pushed the fix/tailwind-v4-shadow-support branch from a3cba9e to 0cb0e65 Compare March 4, 2026 18:37
@YevheniiKotyrlo
Copy link
Author

Hi @danstepanov, hope the NativeWind v4 work is going well! No rush at all — just wanted to let you know this one is rebased on latest main and ready whenever you have a moment.

Since my last comment I've also opened two more PRs on this repo that might be worth looking at together:

Happy to walk through any of them if that would help. Thanks for maintaining this project!

@danstepanov
Copy link
Member

Thanks @YevheniiKotyrlo reviewing this tomorrow

@YevheniiKotyrlo
Copy link
Author

YevheniiKotyrlo commented Mar 8, 2026

Sounds great! I've cleaned up the stack — #284 is now based on this branch's commit (2 stacked commits in #284, reviewable individually via the Commits tab). So reviewing this one first is the right order.

This PR is minimal: just box-shadow.ts inset patterns + tests. All your original feedback has been addressed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants