简体   繁体   English

更改 react-boostrap 单选按钮颜色的正确方法是什么?

[英]What's the proper way to change a react-boostrap radio button color?

What's the proper way to change a react-boostrap radio button color?更改 react-boostrap 单选按钮颜色的正确方法是什么? The default color is blue, but I simply want to change to any random color the correct way.默认颜色是蓝色,但我只是想以正确的方式更改为任何随机颜色。

I'm using ReactJS and my I'm rendering my radio button like this:我正在使用 ReactJS 我正在渲染我的单选按钮,如下所示:

const Radio = ({
    id, type, name, checked, onChange, variant,
}) => (
    <ToggleButton id={id} type={type} name={name} checked={checked} onChange={onChange} variant={variant} />
);

Is this a matter of adding a className where this component is being returned and making an update to the css?这是在返回此组件的位置添加一个类名并对 ZC7A62​​8CBA22E28EB17B5F5C6AE2A266AZ 进行更新的问题吗? If so please advise.如果有,请指教。

Thanks in advance.提前致谢。

Is this a matter of adding a className where this component is being returned and making an update to the css这是在返回此组件的位置添加一个类名并对 ZC7A62​​8CBA22E28EB17B5F5C6AE2A266AZ 进行更新的问题吗

This is one way to do it.这是一种方法。 However, if you are looking to target that variant specifically (or override the existing variants such as primary ), you can do something like this:但是,如果您希望专门针对该变体(或覆盖现有变体,例如primary ),您可以执行以下操作:

.btn-custom-variant {
  background: orange;
}

<ToggleButton variant="custom-variant"/>

Reference: https://react-bootstrap.netlify.app/getting-started/theming/#custom-styles-variants参考: https://react-bootstrap.netlify.app/getting-started/theming/#custom-styles-variants

There generally isn't a "correct" way of doing this.通常没有“正确”的方式来做到这一点。 It depends entirely on your front-end architecture.这完全取决于您的前端架构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM