使用 @fluentui/react-northstar使用组件风格
我正在尝试在我的项目中给出所有< segment>
s边框半径。通过阅读似乎最好的方法是自定义主题中的组件风格。
我已经从NorthStar导入TeamStheme
,创建了一个自定义主题,添加一个段属性并使用deepmerge
软件包合并。我用 this 这是一个跳跃观点。
最终结果是段组件的所有基本样式都丢失了,只有我使用的样式。我错过了什么,以使我的更改与段组件样式合并,而不是覆盖它们。
干杯。
代码示例
import { teamsTheme, Provider } from "@fluentui/react-northstar";
import deepMerge from "deepmerge";
const customTheme = {
componentStyles: {
Segment: {
root: { // Added root here from trial and error. Nothing else seemed to make any changes
borderRadius: 4
}
}
},
};
const theme = deepMerge(teamsTheme, customTheme);
const App () => {
return <Provider theme={theme}>
<Segment>Test</Segment>
</Provider>
}
I am trying to give all the <Segment>
s in my project a border radius. From reading the docs it seems the best way to do this is the componentStyles in a custom theme.
I have imported teamsTheme
from northstar, created a custom theme, adding a Segment property and merged using a deepmerge
package. I used this post as a jumping off point.
The end result is all base styles of the segment component are lost and only the styles I put in used. What have I missed so that my changes are merged with the segment component styling rather than overriding them.
Cheers.
Code example
import { teamsTheme, Provider } from "@fluentui/react-northstar";
import deepMerge from "deepmerge";
const customTheme = {
componentStyles: {
Segment: {
root: { // Added root here from trial and error. Nothing else seemed to make any changes
borderRadius: 4
}
}
},
};
const theme = deepMerge(teamsTheme, customTheme);
const App () => {
return <Provider theme={theme}>
<Segment>Test</Segment>
</Provider>
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我尝试
在这里,我可以更新边框半径和所有
segment
s的框阴影。也许更好的解决方案是使用自定义样式段
而不是更新现有的,但该解决方案现在可以使用。I found this solution when I tried creating a custom component
Here I can update the border radius and the box shadow of all
Segment
s. Maybe the better solution was to use a customStyledSegment
instead of updating the existing but this solution will work for now.