material-ui: [Grid] Unexpected spacing behavior
- 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
Containercomponent 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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 37 (37 by maintainers)
Commits related to this issue
- [Grid] fix: x-scrollbar was showing, closes this issue #24272 Co-authored-by: povilass <povilas810@gmail.com> — committed to greguintow/material-ui by greguintow 3 years ago
- [Grid] fix: x-scrollbar was showing, closes this issue #24272 Co-authored-by: povilass <povilas810@gmail.com> — committed to greguintow/material-ui by greguintow 3 years ago
- [Grid] fix: x-scrollbar was showing, closes this issue #24272 Co-authored-by: povilass <povilas810@gmail.com> — committed to greguintow/material-ui by greguintow 3 years ago
- [Grid] fix: x-scrollbar was showing, closes this issue #24272 Co-authored-by: povilass <povilas810@gmail.com> — committed to greguintow/material-ui by greguintow 3 years ago
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.