Skip to content

Tailwind v4 lineHeightActual is resolved to NaN #265

@alexandernanberg

Description

@alexandernanberg

In Tailwind v4 line heights can be defined as css calc() which breaks

Hacky patch that fixes it

diff --git a/dist/utilities.js b/dist/utilities.js
index a5cad611fbd540ba01cf42d7ac3d9d6d2adf2514..38a5f7fe3c5e8ef6b5117db9765914cd5b4cd484 100644
--- a/dist/utilities.js
+++ b/dist/utilities.js
@@ -79,7 +79,11 @@ function round(value) {
  * custom property.
  */
 function lineHeightProperties(lineHeight, rootSize = 16) {
-    let lineHeightActual = isRelativeValue(lineHeight)
+    let isCssFunction = /^(calc)\s*\(/i.test(lineHeight)
+
+    let lineHeightActual = isCssFunction ? 
+        `calc((${lineHeight}) * var(--font-size-px))`
+        : isRelativeValue(lineHeight)
         ? `calc(${getRelativeValue(lineHeight).toString()} * var(--font-size-px))`
         : normalizeValue(lineHeight, rootSize).toString();
     return {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions