Material-ui: [Grid] Spacing with negative margins results in sometimes imprecise layouts

Created on 9 Feb 2018  路  5Comments  路  Source: mui-org/material-ui

I am using Grid to align-right buttons in a Card. Everything used to look super, but in recent incarnations of material-ui-next, the use of negative margins is resulting in non-ideal presentation with the right negative margin:

screenshot-localhost-3000-2018 02 09-08-10-24

The code for this is:

<CardActions>
  <Grid container justify="flex-end">
    <Grid item>
      (buttons)
    </Grid>
  </Grid>
</CardActions>

Is there a preferred implementation for what I'm trying to achieve here?

breaking change Grid discussion

Most helpful comment

@putzisan you can always make your own Grid with your own default props and simply search/replace imports. This is a simple 5 minutes or less workaround for you.

Now is the time for breaking changes, not post-1.0.

All 5 comments

@bluepeter It's hard to help without a live example of such issue. From your code, you would say that the best option is to use spacing={0}.

- <Grid container justify="flex-end">
+ <Grid container justify="flex-end" spacing={0}>
    <Grid item>

I start to think that it should be the default behavior. The negative margin can really cause trouble. It might not worth having spacing={8} by default. cc @mui-org/core-contributors.

Thank you. Adding spacing={0} to Grid container fixed this for me.

This worked for me, too. 馃憣
Was using spacing={16} or otherwise leaving unspecified. Result was strange on mobile, with small slivers of blank page to the right and bottom I could not account for and that overflow css rule couldn't totally address 馃槀

@oliviertassinari If you introduce this breaking change, it would have a massive impact for an existing v1.0-solution (recheck every Grid-container-use, which is nearly every second component in my projects). would it be possible to add the default-grid-spacing-value in a theme-varaible?

@putzisan you can always make your own Grid with your own default props and simply search/replace imports. This is a simple 5 minutes or less workaround for you.

Now is the time for breaking changes, not post-1.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anthony-dandrea picture anthony-dandrea  路  3Comments

sys13 picture sys13  路  3Comments

pola88 picture pola88  路  3Comments

zabojad picture zabojad  路  3Comments

rbozan picture rbozan  路  3Comments