【问题标题】:How to color label on radio-button on react-materialize如何在反应物化的单选按钮上为标签着色
【发布时间】:2017-10-22 13:09:42
【问题描述】:

如何为使用 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 中的输入元素中。有人可以帮我吗?

谢谢, 雷拉杰

【问题讨论】:

    标签: reactjs materialize


    【解决方案1】:

    react-materialize 中,没有为input &gt; radio &gt; lable 设置class 的选项。

    所以我已经分叉了 repo 并更新了 https://github.com/piyushdhamecha/react-materialize,将 labelClassName 添加到 Input 组件

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

    你可以像这样使用:

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

    【讨论】:

      【解决方案2】:

      您应该创建一个 classnameclassName 的驼峰式案例 reactjs中的样式参考https://facebook.github.io/react/docs/dom-elements.html

      这是 reactmateralize 参考 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>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-10-03
        • 1970-01-01
        • 1970-01-01
        • 2021-11-17
        • 2013-09-14
        • 1970-01-01
        • 1970-01-01
        • 2019-11-23
        相关资源
        最近更新 更多