流利的UI样式无法使用按钮到Commandbar的传递命令来工作

发布于 2025-02-01 17:28:07 字数 1666 浏览 2 评论 0原文

我在项目中使用流利的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:
Styled command bar

I wonder how to set the mouse onhover color in aCommandBar component?

Styled command bar reverted back when mouse hovered over it

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二手情话 2025-02-08 17:28:07

您可以使用按下按钮道具在悬停在悬停的情况下进行更改:

text: 'New Folder',
buttonStyles: {
  iconHovered: {
    color: 'red'
  }
},

在以下方面了解有关此道具的更多信息: https://developer.microsoft.com/en-us/fluentui#/controls/web/commandbar,implementation

You can change it on hover by using buttonStyles prop like this:

text: 'New Folder',
buttonStyles: {
  iconHovered: {
    color: 'red'
  }
},

Find out more about this prop on: https://developer.microsoft.com/en-us/fluentui#/controls/web/commandbar#implementation under section ICommandBarItemProps interface

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文