Skip to content

fix: use :root font-size as compile-time rem base#315

Merged
danstepanov merged 1 commit intomainfrom
fix/root-font-size-rem-override
Mar 31, 2026
Merged

fix: use :root font-size as compile-time rem base#315
danstepanov merged 1 commit intomainfrom
fix/root-font-size-rem-override

Conversation

@danstepanov
Copy link
Copy Markdown
Member

@danstepanov danstepanov commented Mar 31, 2026

Summary

  • When no explicit inlineRem option is passed, the compiler now scans the CSS for :root { font-size: Npx } and uses that value as the rem multiplier instead of hardcoding 14
  • This makes the documented v5 approach for overriding rem actually work without needing to pass inlineRem through metro config
  • Explicit inlineRem option still takes precedence when set

Closes #316

Test plan

  • New test: "rem - css root font-size override" verifies :root { font-size: 16px } produces 16 * 10 = 160 instead of default 14 * 10 = 140
  • Existing "rem - default" test still passes (hardcoded 14 when no :root font-size)
  • Existing "rem - inline override" test still passes (inlineRem option takes precedence)
  • Existing "rem - css override" test still passes (inlineRem: false for runtime resolution)

When no explicit inlineRem option is passed, the compiler now scans CSS
for :root { font-size: Npx } and uses that value as the rem multiplier
instead of hardcoding 14. This makes the documented v5 approach for
overriding rem actually work.

Closes nativewind/nativewind#1650
@danstepanov danstepanov merged commit 7622a38 into main Mar 31, 2026
6 checks passed
@danstepanov danstepanov deleted the fix/root-font-size-rem-override branch March 31, 2026 23:25
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.

v5 inlineRem config not work

1 participant