Skip to content
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

Subtraction in calc() arbitrary values not always normalized properly #9832

Closed
wongjn opened this issue Nov 14, 2022 · 5 comments · Fixed by #10074
Closed

Subtraction in calc() arbitrary values not always normalized properly #9832

wongjn opened this issue Nov 14, 2022 · 5 comments · Fixed by #10074

Comments

@wongjn
Copy link
Contributor

wongjn commented Nov 14, 2022

What version of Tailwind CSS are you using?

v3.2.4

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

Tailwind Play, Webpack v5

What version of Node.js are you using?

v16.13.0

What browser are you using?

Chrome

What operating system are you using?

Ubuntu 18.04 via WSL

Reproduction URL

https://play.tailwindcss.com/KnpyuskR45

Describe your issue

A value like calc(1-(var(--something)*0.5)) or calc(1-var(--something)*0.5) in an arbitrary variant is not normalized properly, with spaces missing around the subtraction operator:

.mt-\[calc\(1-var\(--something\)\*0\.5\)\] {
  margin-top: calc(1-var(--something) * 0.5);
  /* expected margin-top: calc(1 - var(--something) * 0.5); */
}

I would have expected this function consistently akin to the other mathematical operators which seem to be fine:

.mt-\[calc\(1\+\(var\(--something\)\*0\.5\)\)\] {
  margin-top: calc(1 + (var(--something) * 0.5));
}
@thecrypticace thecrypticace self-assigned this Nov 15, 2022
@B54Carey2
Copy link

The only place you can use the calc() function is in values. See these examples where we’re setting the value for a number of different properties.

.el {
font-size: calc(3vw + 2px);
width: calc(100% - 20px);
height: calc(100vh - 20px);
padding: calc(1vw + 5px);
}

@thecrypticace
Copy link
Contributor

I merged in the fix for this in #10074 (thanks @sibbng!). It'll be available in our next release but you can test it in the mean time via our insiders build: npm install tailwindcss@insiders

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.

5 participants
@thecrypticace @wongjn @B54Carey2 and others