[Grid] Unexpected spacing behavior
See original GitHub issue- 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 😯
In the Material UI documentation on the Grid component examples, it works fine inside the main container when using spacing
Expected Behavior 🤔
What is expected is that if I copy and paste the same example code to be able to test it will behave in the same way, but this does not work Link to codesandbox
It ends up generating a horizontal scroll.
Some solutions are given, but I don’t see these being used in the example.
- We are using a
Container
component as parent
Steps to Reproduce 🕹
Steps:
- Copy NestedGrid code example
- Paste to codesandbox
- Run app
Context 🔦
We were building a Layout for a page and we were in doubt regarding the spacing of the Grid component since we began to have several problems with horizontal scrolling.
Our implementation is
container: {
paddingTop: 8,
paddingBottom: 8,
}
<Container className={classes.container}>
<Grid container spacing={2}>
<Grid item xs>
...
</Grid>
</Grid>
</Container>
Your Environment 🌎
Material UI v4.11.2 React v17.0.1
`npx @material-ui/envinfo`
Don't forget to mention which browser you used.
Output from `npx @material-ui/envinfo` goes here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:37 (37 by maintainers)
Top Results From Across the Web
[Grid] Unexpected spacing behavior #24272 - mui/material-ui
We were building a Layout for a page and we were in doubt regarding the spacing of the Grid component since we began...
Read more >MUI - V5 Grid System spacing not producing gutters between ...
The behavior of the MUI grid spacing is a bit unexpected since it moves the grid items to the bottom right. To keep...
Read more >Can't adjust repeat grid spacing - Adobe Support Community
The repeat grid must be selected to adjust the spacing. If it's not selected you won't be able to alter the spacing.
Read more >MUI Grid Spacing, Padding, and Margin: A Styling Guide
The spacing prop must be applied on Grids with nested child Grid items (and it only affects the child elements); The spacing prop...
Read more >Two flexbox & grid behaviors most people don't know about
When we use flex and grid, there are a lot of things that we know are going to happen, like getting columns and...
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
I don’t think that it matter
Ok example showed problem bus still you need applied half spacing size to parent https://codesandbox.io/s/new-cache-lrynu like the documentation says.