How to center a component in Material-UI and make it responsive?
Since you are going to use this in a login page. Here is a code I used in a Login page using Material-UI
<Grid
container
spacing={0}
direction="column"
alignItems="center"
justify="center"
style={{ minHeight: '100vh' }}
>
<Grid item xs={3}>
<LoginForm />
</Grid>
</Grid>
this will make this login form at the center of the screen.
But still IE doesn't support the Material-UI Grid and you will see some misplaced content in IE.
Hope this will help you.
Another option is:
<Grid container justify = "center">
<Your centered component/>
</Grid>
The @Nadun's version did not work for me, sizing wasn't working well. Removed the direction="column"
or changing it to row
, helps with building vertical login forms with responsive sizing.
<Grid
container
spacing={0}
alignItems="center"
justify="center"
style={{ minHeight: "100vh" }}
>
<Grid item xs={6}></Grid>
</Grid>;