如何获得输入单选元素以在react [material-ui]中水平对齐? [英] How can I get input radio elements to horizontally align in react [material-ui]?

查看:46
本文介绍了如何获得输入单选元素以在react [material-ui]中水平对齐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在material-ui中列出的无线电组始终是垂直的.有没有办法将它们水平对齐?例如所有单选按钮都在一条水平线上.

The radio group is always vertical listed in material-ui. Is there a way to horizontally align them? e.g. all radio button in one horizontal line.

推荐答案

只需使用 row 属性:

Simply use the row property:

<RadioGroup row><Radio /><Radio /></RadioGroup>

RadioGroup 继承自 FormGroup ,因此 FormGroup 的属性组件也可用.

RadioGroup inherits from FormGroup so the properties of the FormGroup component are also available.

另一个示例,带有标签:

Another example, with labels:

<RadioGroup aria-label="anonymous" name="anonymous" value={false} row>
  <FormControlLabel value="true" control={<Radio />} label="Yes" />
  <FormControlLabel value="false" control={<Radio />} label="No" />
</RadioGroup>

这篇关于如何获得输入单选元素以在react [material-ui]中水平对齐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆