-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Always return value with 'px' unit in the spacing function #16205
Comments
@rash2x We have people doing transformations with it: For now, you can do the following: const theme = createMuiTheme({
spacing: x => `${x * 8}px`,
}); |
+1 on this, it's really easy to mix up things with the current behavior
Here I must put Later I decide to refactor it and make a quick change:
Now it's invalid again, for a different reason (double |
@emirotin Please upvote the issue, it will make it more likely to land in v5 :) |
Done :)
which works with a bare number just fine because of JSS. Later I decide to make it 40px/auto and change it to:
And now it doesn't work. |
This change would break |
Alternatively MUI can stop adding 'px' altogether and rely on the jss space-separated syntax: |
@emirotin I think that we should optimize for styled-components not JSS. |
My idea was under the hood you're using JSS so relying on its native features sounds logical. Also given you allow passing the custom
It will basically be backward-compatible in almost every normal usage:
|
@emirotin The plan is to change the default style engine to styled-components in v5, while keeping JSS for backward compatibility. We need a strategy that works with the majorities of the styling solutions. This array feature comes in a JSS plugin we don't load to minimize bundle size. |
This would still be overridable correct? We like to configure spacing to use spacing: (factor) => `${0.5 * factor}rem`, |
@pachuka Yes, we would still allow developers to change the unit. |
Would this be good enough? -padding: theme.spacing(4) + 1
+padding: `calc(${theme.spacing(4)} + 1px)`, |
Hi guys,
We use styled-components as CSS framework and when we call the spacing function with the single argument we have to put 'px' unit in the end, but with multiple arguments, we don't need to do it. It's a little confusing because by changing the number of arguments a developer should add or remove 'px' unit.
Expected Behavior 🤔
Example:
Result
Current Behavior 😯
Example:
Result
So, now when we use single argument we always put 'px' in the end as the example below:
The text was updated successfully, but these errors were encountered: