React Fluent UI - 更改复选框选中标记和标签的颜色
我有一个使用 Fluent UI 的 React 应用程序。我正在使用
组件,但它具有默认颜色和行为。像这样:
我想更改选中标记和标签的颜色(绿色选中标记和棕色标签)。我尝试了以下方法来执行此操作,但没有成功。
const checkBoxStyles = {
root: {
color: 'brown'
},
checkbox: {
color:'green'
}
}
return (
<Stack tokens={stackTokens}>
<Checkbox
styles={checkBoxStyles}
label="Controlled checkbox"
checked={isChecked}
onChange={onChange}
/>
</Stack>
);
};
codepen 上的完整工作代码 - https://codepen.io/AnkitSaxena2605/pen/eYyppLj
I've a react app using Fluent UI. I'm using <Checkbox/>
component but it's having it's default colors and behavious. Like this:
I want to change the color of the checked mark and also the label (Green checked mark and brown lable). I tried the below way to do so but it didn't work.
const checkBoxStyles = {
root: {
color: 'brown'
},
checkbox: {
color:'green'
}
}
return (
<Stack tokens={stackTokens}>
<Checkbox
styles={checkBoxStyles}
label="Controlled checkbox"
checked={isChecked}
onChange={onChange}
/>
</Stack>
);
};
Full working code at codepen - https://codepen.io/AnkitSaxena2605/pen/eYyppLj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在
checkBoxStyles
中进行以下更改:checkbox
和checkmark
用于设置复选框样式,text
用于设置复选框样式设计标签的样式。Try to do the following changes in your
checkBoxStyles
:checkbox
andcheckmark
are for styling the checkbox andtext
is for styling the label.