Skip to content

Incorrect formatting of valid hyphenated values placed inside a CSS function: fit-content becomes fit - content #18219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rozsazoltan opened this issue Jun 4, 2025 · 1 comment · May be fixed by #18220

Comments

@rozsazoltan
Copy link

What version of Tailwind CSS are you using?

For example: v4.1.8

What build tool (or framework if it abstracts the build tool) are you using?

Tailwind Play

Reproduction URL

https://play.tailwindcss.com/kbBgEMHTsM

Describe your issue

<div class="min-h-[min(fit-content,calc(100dvh-4rem))]"></div>

The expected result would be:

.min-h-\[min\(fit-content\,calc\(100dvh-4rem\)\)\] {
  min-height: min(fit-content, calc(100dvh - 4rem));
}

Instead - since it's inside a min() function - every hyphen gets surrounded by spaces:

.min-h-\[min\(fit-content\,calc\(100dvh-4rem\)\)\] {
  min-height: min(fit - content, calc(100dvh - 4rem));
}
@rozsazoltan
Copy link
Author

// Add whitespace around operators inside math functions
else if ((char === '+' || char === '*' || char === '/' || char === '-') && formattable[0]) {
let trimmed = result.trimEnd()
let prev = trimmed[trimmed.length - 1]
// If we're preceded by an operator don't add spaces
if (prev === '+' || prev === '*' || prev === '/' || prev === '-') {
result += char
continue
}
// If we're at the beginning of an argument don't add spaces
else if (prev === '(' || prev === ',') {
result += char
continue
}
// Add spaces only after the operator if we already have spaces before it
else if (input[i - 1] === ' ') {
result += `${char} `
}
// Add spaces around the operator
else {
result += ` ${char} `
}
}

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 a pull request may close this issue.

1 participant