The spacing appears to be working well when examining the grid elements with devtools. The issue lies in the bgcolor="lightblue"
attribute on the <Grid container>
, which covers the entire grid container and obscures any spacing from the individual grid items.
If you utilize the following grid structure, you'll notice that the spacing functions properly and the previous problem was simply a color-related error:
<Grid container height="60px" spacing={2}>
<Grid item xs={3}>
<Box bgcolor="lightblue" height="100%" width="100%">
1
</Box>
</Grid>
<Grid item xs={3}>
<Box bgcolor="lightblue" height="100%" width="100%">
2
</Box>
</Grid>
<Grid item xs={3}>
<Box bgcolor="lightblue" height="100%" width="100%">
3
</Box>
</Grid>
<Grid item xs={3}>
<Box bgcolor="lightblue" height="100%" width="100%">
4
</Box>
</Grid>
</Grid>