【发布时间】:2020-04-06 04:46:21
【问题描述】:
我一直在创建一组可重用组件,我使用 classes 属性对其进行样式化以覆盖 MUI 类名。然后我将许多常见的样式提取到一个主题中,以避免在更复杂的组件中重复。主题是使用withTheme HOC 包装每个组件。
我现在意识到有些地方我们需要为一次性案例覆盖样式。我认为我应该能够使用 withStyles HOC 来做到这一点,但它似乎对我不起作用。
https://codesandbox.io/s/overriding-a-withtheme-with-withstyle-hoc-0m9cmCodepen
MyReusableThemedComponent - 是可重用组件(实际上只是用主题包装 Material UI 选项卡)
CustomOverideTabs - 是我的 MyReusableThemedComponent 的实现,我试图通过使文本小写来覆盖 Material-UI textTransform。
const StyledTabs = withStyles({ root: { textTransform: "lowercase" } })(
MyReusableThemedComponent
);
我相信 transform: uppercase 是 MuiTab-root 类的默认设置,但即使在主题中指定它似乎也没有什么区别。
TIA
【问题讨论】:
标签: css reactjs tabs themes material-ui