我无法弄清楚我是否正在使用正确的方法让登录/退出按钮在使用material-ui-next(" material-ui" :" ^ 1.0.0-beta.22",)
似乎他们从api中删除了iconElementRight=
。我们现在必须在appbar中使用<Grid>
吗?感觉有点笨拙。什么是在appbar中浮动按钮(例如登录)的正确方法?
<AppBar position="static">
<Toolbar>
<Grid container spacing={24}>
<Grid item xs={11}>
<Typography type="title" color="inherit">
Title
</Typography>
</Grid>
<Grid item xs={1}>
<div>
<HeartIcon />
<Button raised color="accent">
Login
</Button>
</div>
</Grid>
</Grid>
</Toolbar>
</AppBar>
答案 0 :(得分:24)
您需要将flex: 1
添加到<Typography />
组件,以便将<div />
推送到AppBar的最右侧:
<AppBar position="static">
<Toolbar>
<Typography type="title" color="inherit" style={{ flex: 1 }}>
Title
</Typography>
<div>
<HeartIcon />
<Button raised color="accent">
Login
</Button>
</div>
</Toolbar>
</AppBar>
答案 1 :(得分:15)
@Kyle您说对了:)
只需添加到网格容器中即可
justify =“ space-between”
以您的示例为例:
<AppBar position="static">
<Toolbar>
<Grid
justify="space-between" // Add it here :)
container
spacing={24}
>
<Grid item>
<Typography type="title" color="inherit">
Title
</Typography>
</Grid>
<Grid item>
<div>
<HeartIcon />
<Button raised color="accent">
Login
</Button>
</div>
</Grid>
</Grid>
</Toolbar>
</AppBar>