MUI - How to align a component to the center/right?
·
Answer a question
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.
Answers
BEFORE MUI 5:
Try this
<Grid container justify="flex-end">
<Button>Example</Button>
</Grid>
UPDATE MUI 5: (Thanks to Dipak)
The prop
justifyofForwardRef(Grid)is deprecated. UsejustifyContentinstead, 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.
更多推荐
所有评论(0)