Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(web): add lineHeight to unitless CSS properties#3937

Open
lightstrike wants to merge 2 commits into
tamagui:maintamagui/tamagui:mainfrom
lightstrikelabs:fix/web-unitless-line-heightlightstrikelabs/tamagui:fix/web-unitless-line-heightCopy head branch name to clipboard
Open

fix(web): add lineHeight to unitless CSS properties#3937
lightstrike wants to merge 2 commits into
tamagui:maintamagui/tamagui:mainfrom
lightstrikelabs:fix/web-unitless-line-heightlightstrikelabs/tamagui:fix/web-unitless-line-heightCopy head branch name to clipboard

Conversation

@lightstrike

Copy link
Copy Markdown
Collaborator

Summary

  • Numeric lineHeight values (e.g., 1.15) were incorrectly getting px appended during CSS extraction, producing line-height:1.15px instead of line-height:1.15
  • Per CSS spec, unitless line-height is a multiplier of font-size — 1.15px is an absolute ~1px height that causes text to visually collapse
  • Added lineHeight to stylePropsUnitless (helpers) and unitlessNumbers (react-native-web-internals) so both runtime and compiler paths treat it as unitless
  • Native/RN is unaffected — normalizeValueWithProperty bails on !isWeb before consulting the unitless list

Trade-offs

  • In React Native, lineHeight: 62 means 62 absolute pixels. After this fix, on web it becomes line-height: 62 (a 62x multiplier). However:
    • Font tokens resolve to CSS variables (strings), not raw numbers — unaffected
    • Users who need absolute px on web can write lineHeight: '62px'
    • This matches CSS spec and how other CSS-in-JS libraries handle lineHeight

Test plan

  • Added 5 new tests to getStylesAtomic.web.test.tsx: numeric lineHeight, integer lineHeight, string percentage passthrough, opacity unitless guard, fontSize px guard
  • All 161 existing core-test web tests pass with zero regressions

@lightstrike
lightstrike marked this pull request as ready for review February 28, 2026 00:15
@natew

natew commented Mar 9, 2026

Copy link
Copy Markdown
Member

Tied into the flex one, this is one where if we're aligning to web then we'd want to do that, but it's a breaking change and would have to be in v3.

@natew natew left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. The fix is correct — CSS spec defines unitless line-height as a font-size multiplier, so appending px to numeric values was always wrong (e.g. lineHeight: 1.15 producing line-height: 1.15px which collapses text to ~1px). Both stylePropsUnitless and unitlessNumbers need to be in sync for the runtime and compiler paths respectively, and the PR correctly updates both. The \!isWeb guard in normalizeValueWithProperty ensures native is unaffected. Font token values go through getVarRef and resolve to CSS variables (strings), so they're unaffected. The breaking change for users passing raw integer lineHeight props directly (e.g. lineHeight={24}) is warranted — the previous behavior was the bug. Tests are thorough.

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.