I want to align my button to the right of the parent.
I was wondering if there is a proper way to do it in MUI. I could use:
<Grid container justify="flex-end">
But then I would have to use another <Grid item />
. Seems too much of work.
Or maybe I am just better off using plain old CSS, messing around with float: right
and dealing with the apparent zero height of the element.
Since direction=”row”, we have to manually set the center alignment both vertically and horizontally. On the “Bottom Center” item, alignItems=“flex-end” adds the vertical bottom alignment and justify=“center” adds the horizontal centering.
To center a component horizontally and vertically in React. js, set its display property to flex and its alignItems and justifyContent properties to center . The components's content will be horizontally and vertically centered. Copied!
Try this
<Grid container justify="flex-end"> <Button>Example</Button> </Grid>
The prop
justify
ofForwardRef(Grid)
is deprecated. UsejustifyContent
instead, the prop was renamed.
<Grid container justifyContent="flex-end"> <Button>Example</Button> </Grid>
Update: The best solution is the answer of NearHuscarl, you'd better use Stack than Grid.
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