[Theming] theme.spacing doesn't accept multiple string arguments
See original GitHub issueUsing a custom function for theme.spacing
with multiple arguments (theme.spacing("xs", "sm")
) used to work in v4.8
, now it doesn’t.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Given a custom spacing function like:
const customSpacing = key => {
const mySpacings = { xs: 10, sm: 30, lg: 50 };
return mySpacings[key] || key;
};
And applying it like so: padding: theme.spacing("sm", "xs")
The output is: padding: sm xs
Expected Behavior 🤔
Expected the output to be padding: 30px 10px
Steps to Reproduce 🕹
CodeSandbox of the example above: https://codesandbox.io/s/material-demo-sv3h3?file=/demo.js:430-455
If you change to "@material-ui/core": "~4.8.0"
it works fine
Steps:
- Notice how the
div
padding isn’t properly applied (inspect the reddiv
element)
Context 🔦
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v4.10.0 |
React | |
Browser | |
TypeScript | |
etc. |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (8 by maintainers)
Top Results From Across the Web
[Theming] theme.spacing doesn't accept multiple string ...
Using a custom function for theme.spacing with multiple arguments ( theme.spacing("xs", "sm") ) used to work in v4.8 , now it doesn't.
Read more >how theme.spacing() is functioning? - Stack Overflow
const theme = createMuiTheme({ spacing: 8, });. When your theme is define, you have a spacing value. By default this value is 8px...
Read more >Spacing - Material UI - MUI
Use the theme.spacing() helper to create consistent spacing between the elements ... Multiple arity. The theme.spacing() helper accepts up to 4 arguments.
Read more >API Reference - styled-components
Returns a function that accepts a tagged template literal and turns it into a ... will receive the styled component's props as the...
Read more >Global Styling with Material-UI Theme Overrides and Props
Learn how to use global CSS overrides and default props in a theme to customize all instances of a Material-UI component in a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zettca Thanks for sharing more details on how you use the spacing function. I think that we all agree that it’s the desired direction to go into. The question at stake is: how?
I can implement @oliviertassinari’s proposed solution, if that’s okay with you guys 😃