如何在react-materialize上的单选按钮上标记颜色

时间:2017-08-05 06:21:32

标签: reactjs materialize

如何为使用 react-materialize 输入组件创建的单选按钮的标签着色?

radioButtons的示例代码是这样的吗?

<div className="col s2 offset-s3">
    <Input className="with-gap" label="List" name="homePageSearchRadio" type="radio" value="group"/>
</div>
<div className="col s2">
    <Input className="with-gap" label="User" name="homePageSearchRadio" type="radio" value="user"/>
</div>
<div className="col s2">
    <Input className="with-gap" label="data" name="homePageSearchRadio" type="radio" value="data"/>
</div>

我尝试添加样式属性,但这实际上是添加到html中的input元素。有人可以帮助我吗?

谢谢, Sreeraj

2 个答案:

答案 0 :(得分:0)

您应该classname创建className的驼峰案例 这个关于reactjs https://facebook.github.io/react/docs/dom-elements.html

样式的参考

这用于反应性参考 https://react-materialize.github.io/#/forms

<div className="col s2 offset-s3">
    <Input className="with-gap" label="List" name="homePageSearchRadio" type="radio" value="group"/>
</div>
<div classname="col s2">
    <Input className="with-gap" label="User" name="homePageSearchRadio" type="radio" value="user"/>
</div>
<div classname="col s2">
    <Input className="with-gap" label="data" name="homePageSearchRadio" type="radio" value="data"/>
</div>

答案 1 :(得分:0)

In react-materialize there is no option to set class for input > radio > lable.

So i have fork the repo and updated https://github.com/piyushdhamecha/react-materialize, added labelClassName to Input component

npm install --save https://github.com/piyushdhamecha/react-materialize

You can use like:

<Input labelClassName="radioLabel" className="with-gap" label="List" name="homePageSearchRadio" type="radio" value="group"/>