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

Negative spacing broken when using css variables and an array as spacing transformation #45500

Closed
drskullster opened this issue Mar 6, 2025 · 0 comments · Fixed by #45550
Closed
Assignees
Labels
bug 🐛 Something doesn't work customization: css Design CSS customizability package: system Specific to @mui/system

Comments

@drskullster
Copy link

drskullster commented Mar 6, 2025

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/react-pzfbrtbw?file=Demo.tsx
  2. Notice that when using a number or a function is passed to the spacing property of the createTheme function, things work as expected
  3. But if you pass an array, negative margins don't work anymore.
  4. Comment the cssVariables: true property and notice that negative spacing when passing an array to the spacing property works as expected

Current behavior

When using css variables and defining an array for the theme.spacing property, then trying to use a negative spacing in the sx utility, the value will be transformed to 0.

Note that interestingly there's a difference between the stackblitz repro and my local environment. In my local env, the value is transformed to -var(--mui-spacing-2). I'm on v6.3.1 though, didn't see anyting related to tthis in the changelog but I might have missed it.

Expected behavior

Ideally the transformation would result to calc(-1 * var(--mui-spacing-2))

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: negative spacing css variables

@drskullster drskullster added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 6, 2025
@zannager zannager added package: system Specific to @mui/system customization: css Design CSS customizability labels Mar 7, 2025
@siriwatknp siriwatknp added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work customization: css Design CSS customizability package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants