Skip to content

Conversation

@alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Oct 31, 2025

Description

Updates line-height calculations to follow font-sizing approach to fix discrepancies between browsers.

BEFORE AFTER
Screenshot 2025-10-31 at 1 17 22 PM Screenshot 2025-10-31 at 1 17 58 PM

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Bug Fixes
    • Improved typography line-height and font-sizing alignment to enhance consistency across browsers and reduce visual discrepancies in text rendering.

@vercel
Copy link

vercel bot commented Oct 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Oct 31, 2025 3:32pm

@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2025

🦋 Changeset detected

Latest commit: 45f5c10

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

Walkthrough

A changeset entry is added for @clerk/clerk-js with a patch version bump. Line-height values in the typography module are refactored from decimal strings to fractional expressions for improved consistency with font-sizing calculations and reduced cross-browser rendering differences.

Changes

Cohort / File(s) Summary
Changeset entry
.changeset/twenty-sides-take.md
Patch version bump documenting line-height calculation refinements.
Typography constants
packages/clerk/src/ui/foundations/typography.ts
Line-height values (extraSmall, small, medium, large) converted from decimal strings to fractional expressions; corresponding FONT_SIZE_SCALE_RATIOS entries updated with fractional notation and decimal equivalents.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that fractional-to-decimal conversions are mathematically equivalent to original values
  • Confirm the refactored constants produce expected line-height rendering across browsers

Poem

Lines measured true by fractions wise,
No decimals cloud the rabbit's eyes,
Typography springs forth so neat,
Cross-browser harmony—what a treat! 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix(clerk-js): Variable line-height discrepancy" is directly related to the main changes in this pull request. The changeset updates line-height calculations from decimal strings to fractional expressions in the typography.ts file, specifically to address rendering discrepancies between browsers. The title accurately captures this primary objective by identifying that a line-height discrepancy is being fixed. The title is concise, uses standard commit formatting, and is specific enough that a developer reviewing the commit history would understand the nature of the change without needing additional context.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch alexcarpenter/fix-line-height-discrepency

Comment @coderabbitai help to get the list of available commands and usage tips.

@alexcarpenter
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @alexcarpenter - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.1.45-snapshot.v20251031154207
@clerk/astro 2.14.3-snapshot.v20251031154207
@clerk/backend 2.19.2-snapshot.v20251031154207
@clerk/chrome-extension 2.7.11-snapshot.v20251031154207
@clerk/clerk-js 5.103.2-snapshot.v20251031154207
@clerk/elements 0.23.76-snapshot.v20251031154207
@clerk/clerk-expo 2.17.4-snapshot.v20251031154207
@clerk/expo-passkeys 0.4.13-snapshot.v20251031154207
@clerk/express 1.7.44-snapshot.v20251031154207
@clerk/fastify 2.5.1-snapshot.v20251031154207
@clerk/localizations 3.26.5-snapshot.v20251031154207
@clerk/nextjs 6.34.2-snapshot.v20251031154207
@clerk/nuxt 1.11.3-snapshot.v20251031154207
@clerk/clerk-react 5.53.5-snapshot.v20251031154207
@clerk/react-router 2.1.7-snapshot.v20251031154207
@clerk/remix 4.13.10-snapshot.v20251031154207
@clerk/shared 3.30.0-snapshot.v20251031154207
@clerk/tanstack-react-start 0.26.6-snapshot.v20251031154207
@clerk/testing 1.13.10-snapshot.v20251031154207
@clerk/themes 2.4.31-snapshot.v20251031154207
@clerk/types 4.97.0-snapshot.v20251031154207
@clerk/vue 1.14.10-snapshot.v20251031154207

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/[email protected] --save-exact

@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/expo-passkeys

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-react-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

@alexcarpenter alexcarpenter marked this pull request as ready for review October 31, 2025 17:20
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.changeset/twenty-sides-take.md (1)

1-5: LGTM! Changeset follows conventions.

The patch version bump is appropriate for this bug fix, and the description clearly communicates the intent. Optionally, you could make the description more specific by mentioning the change from decimal to fractional format (e.g., "Updates line-height calculations from decimal strings to fractional expressions to align with font-sizing approach and reduce cross-browser rendering differences").

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f47b5a3 and 45f5c10.

📒 Files selected for processing (2)
  • .changeset/twenty-sides-take.md (1 hunks)
  • packages/clerk-js/src/ui/foundations/typography.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/twenty-sides-take.md
packages/clerk-js/src/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)

packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure

Files:

  • packages/clerk-js/src/ui/foundations/typography.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/ui/foundations/typography.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/ui/foundations/typography.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/foundations/typography.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/ui/foundations/typography.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/ui/foundations/typography.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/ui/foundations/typography.ts
🔇 Additional comments (1)
packages/clerk-js/src/ui/foundations/typography.ts (1)

23-27: LGTM! Consistent fractional format.

The fractional expressions with decimal equivalents in comments provide good clarity. This format works correctly since these values are consumed within calc() expressions (as seen on lines 34-38), where division is properly evaluated.

Comment on lines +12 to +15
extraSmall: '16 / 12', // = 1.33333
small: '18 / 13', // = 1.38462
medium: '24 / 17', // = 1.41176
large: '16 / 11', // = 1.45455
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify that lineHeight consumers support fractional expressions.

The fractional format (e.g., '16 / 12') aligns with the font-sizing approach used in FONT_SIZE_SCALE_RATIOS, but this is only valid CSS when wrapped in calc(). Unlike FONT_SIZE_SCALE_RATIOS (which are explicitly used inside calc() on lines 34-38), the consumption of lineHeights is not visible in this file.

Run the following script to verify how lineHeights are consumed and whether they're properly wrapped in calc():


🏁 Script executed:

#!/bin/bash
# Description: Find all usages of lineHeights to verify fractional format compatibility

# Search for lineHeights usage patterns
rg -n -C3 --type=ts --type=tsx 'lineHeights\.' packages/clerk-js/src/

# Also check for direct object access
rg -n -C3 --type=ts --type=tsx 'from.*typography.*lineHeights' packages/clerk-js/src/

Length of output: 55



---

🏁 Script executed:

```shell
#!/bin/bash
# Description: Find lineHeights usage with corrected rg syntax

# Search for lineHeights imports and usages without type filters
rg -n -C3 'lineHeights' packages/clerk-js/src/ --glob='*.ts' --glob='*.tsx'

# Also search for where typography is imported
rg -n -C3 'from.*typography' packages/clerk-js/src/ --glob='*.ts' --glob='*.tsx'

# Search for calc\(\s*\$\{.*lineHeights to see if wrapped in calc
rg -n -C2 'calc.*lineHeights|lineHeights.*calc' packages/clerk-js/src/ --glob='*.ts' --glob='*.tsx'

Length of output: 8180



---

🏁 Script executed:

```shell
#!/bin/bash
# Description: Verify how typography style objects (h1, h2, etc.) are consumed

# Find where common.ts exports are used
rg -n -C3 'from.*common' packages/clerk-js/src/ui/ --glob='*.ts' --glob='*.tsx'

# Search for how typography preset styles are applied
rg -n 'h1|h2|h3|subtitle|body|caption|buttonLarge|buttonSmall' packages/clerk-js/src/ui/styledSystem/common.ts -A1 -B1

# Check if there's styled-system configuration that processes lineHeight
rg -n -C5 'lineHeight' packages/clerk-js/src/ui/styledSystem/ --glob='*.ts' --glob='*.tsx'

Length of output: 66783



---

🏁 Script executed:

```shell
#!/bin/bash
# Find how the typography presets from common.ts are exported and used

# Check what common.ts exports
rg -n 'export.*common' packages/clerk-js/src/ui/styledSystem/index.ts -A5

# Find usage of the typography presets (h1, h2, h3, subtitle, body, etc.)
rg -n '\bh1\b|\bh2\b|\bh3\b|\bsubtitle\b' packages/clerk-js/src/ui/ --glob='*.ts' --glob='*.tsx' -B2 -A2 | head -100

# Check if there's any CSS-in-JS library processing (e.g., styled-components, emotion)
rg -n 'css|styled' packages/clerk-js/src/ui/styledSystem/createVariants.ts -A5 | head -50

# Look for where lineHeight values get processed
rg -n 'lineHeight' packages/clerk-js/src/ui/styledSystem/createVariants.ts -B3 -A3

Length of output: 6998



---

🏁 Script executed:

```shell
#!/bin/bash
# Find textVariants function definition in common.ts

# Show the entire common.ts file to understand structure
cat packages/clerk-js/src/ui/styledSystem/common.ts

# Also check if there's any processing of lineHeight values elsewhere
rg -n 'textVariants' packages/clerk-js/src/ui/ --glob='*.ts' --glob='*.tsx' -B2 -A2

Length of output: 12688


Wrap lineHeight values in calc() to fix invalid CSS syntax.

The fractional format (e.g., '16 / 12') used in lineHeights is invalid CSS syntax unless wrapped in calc(). Unlike FONT_SIZE_SCALE_RATIOS, which are properly wrapped in calc() on lines 34-38 of packages/clerk-js/src/ui/foundations/typography.ts, the lineHeights values are spread directly into style objects without calculation wrapping. This will cause browsers to reject these values and fall back to inherited line-height, breaking the intended typography scaling.

Update lineHeights in packages/clerk-js/src/ui/foundations/typography.ts (lines 12-15) to wrap fractional expressions in calc():

extraSmall: 'calc(16 / 12)', // = 1.33333
small: 'calc(18 / 13)', // = 1.38462
medium: 'calc(24 / 17)', // = 1.41176
large: 'calc(16 / 11)', // = 1.45455
🤖 Prompt for AI Agents
In packages/clerk-js/src/ui/foundations/typography.ts around lines 12 to 15, the
lineHeights entries use raw fractional strings like '16 / 12' which are invalid
CSS when emitted into style objects; wrap each fractional expression in calc(),
e.g. change '16 / 12' to 'calc(16 / 12)' (and similarly for '18 / 13', '24 /
17', '16 / 11') so the generated CSS is valid and browsers compute the intended
numeric line-height.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants