I'm having trouble understanding how to align items in MUI. I have the following code:
class SignUpForm extends React.Component {
render() {
return (
<Button sx={{ justifyContent: "flex-end" }}
color="inherit" }>Sign Up</Button>
)
}
}
which is composed by:
class Nav extends React.Component {
render() {
return (
<Box sx={{ flexGrow: 1}}>
<AppBar position="static">
<Toolbar>
<SignUpForm />
</Toolbar>
</AppBar>
</Box>
)
}
}
But unfortunately the content is still staying to the left. Using this resource
Thank you.
CodePudding user response:
I'm pretty sure you just need to change sx={{ justifyContent: "flex-end" }}
to sx={{ marginLeft: "auto" }}
on the Button
CodePudding user response:
Toolbar
is a flexbox, so you can add a div
on the left side and set justify-content
to space-between
to push the Button
to the right:
<Toolbar sx={{ justifyContent: "space-between" }}>
<div />
<SignUpForm />
</Toolbar>