流利的UI样式无法使用按钮到Commandbar的传递命令来工作
我在项目中使用流利的UI,我不知道如何在commandbar
中更改on Holphover
样式。
我对此进行了初始化的按钮:
// inside `buttons` array
key: 'newfolder',
text: 'New Folder',
iconProps: {
iconName: 'NewFolder',
styles: {
root: {
color: 'orange'
},
rootHovered: {
color: 'red'
}
}
},
onClick: ...
然后,我将这些按钮传递到commandbar
:
<CommandBar
items={buttons}
styles={{
root: {
paddingLeft: '5px'
},
}}
/>
我想知道如何在commandbar
组件中设置鼠标on Hover
color?
如您所见,即使我将红色
作为hoothed
color的颜色传递给,它仍然是蓝色的。我不能将悬停
prop传递给commandbar
,因为我会收到以下错误:
(property) rootHovered: {}
Type '{ root: { paddingLeft: string; }; rootHovered: {}; }' is not assignable to type 'IStyleFunctionOrObject<ICommandBarStyleProps, ICommandBarStyles> | undefined'.
Object literal may only specify known properties, and 'rootHovered' does not exist in type 'IStyleFunctionOrObject<ICommandBarStyleProps, ICommandBarStyles>'.ts(2322)
I am using Fluent UI in my project, and I don't know how to change onhover
style in the CommandBar
.
I initialised my buttons with this:
// inside `buttons` array
key: 'newfolder',
text: 'New Folder',
iconProps: {
iconName: 'NewFolder',
styles: {
root: {
color: 'orange'
},
rootHovered: {
color: 'red'
}
}
},
onClick: ...
Then I am passing these buttons to CommandBar
:
<CommandBar
items={buttons}
styles={{
root: {
paddingLeft: '5px'
},
}}
/>
This has allowed me to override the default color:
I wonder how to set the mouse onhover
color in aCommandBar
component?
As you can see, it is still blue even though I passed red
as rootHovered
color. I can't pass Hovered
prop to CommandBar
because I get the following error:
(property) rootHovered: {}
Type '{ root: { paddingLeft: string; }; rootHovered: {}; }' is not assignable to type 'IStyleFunctionOrObject<ICommandBarStyleProps, ICommandBarStyles> | undefined'.
Object literal may only specify known properties, and 'rootHovered' does not exist in type 'IStyleFunctionOrObject<ICommandBarStyleProps, ICommandBarStyles>'.ts(2322)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用按下按钮道具在悬停在悬停的情况下进行更改:
在以下方面了解有关此道具的更多信息: https://developer.microsoft.com/en-us/fluentui#/controls/web/commandbar,implementation
You can change it on hover by using buttonStyles prop like this:
Find out more about this prop on: https://developer.microsoft.com/en-us/fluentui#/controls/web/commandbar#implementation under section
ICommandBarItemProps interface