I have a Grid container and Buttons as it's children (Grid-items). I want to align Grid-items vertically centered.
Here is the visual representation of my requirement

Here is the markup
<Box height="10vh" mr={4}>
<Grid container justify="flex-end" spacing={2}>
<Button variant="contained" color="default" type="reset">
Reset
</Button>
<Button
type="submit"
variant="contained"
color="primary"
onClick={() => handleSubmit()}
>
Search
</Button>
</Grid>
</Box>;
Can anybody tell me a solution based on material-ui grid API?
I figured out, this should work,
const useStyles = makeStyles({
grid: {
height: "100%"
}
});
export default function Hook() {
const classes = useStyles();
return (
<Box height="10vh" mr={4}>
<Grid
className={classes.grid}
container
justify="flex-end"
alignItems="center"
spacing={2}
>
<Button variant="contained" color="default" type="reset">
Reset
</Button>
<Button
type="submit"
variant="contained"
color="primary"
onClick={console.log}
>
Search
</Button>
</Grid>
</Box>
);
}
Working sandbox, https://codesandbox.io/s/material-demo-forked-m7fyj?file=/demo.js

<Grid
container
direction="row"
justifyContent="flex-end"
alignItems="center"
>

I recommend you to try the Interactive Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With