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 justify of ForwardRef(Grid) is deprecated. Use justifyContent 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.

Logo

React社区为您提供最前沿的新闻资讯和知识内容

更多推荐