【发布时间】:2021-05-13 16:29:49
【问题描述】:
我一辈子都不知道如何更改包装在 reactjs 按钮组件中的文本的字体系列。我已经尝试过类覆盖,但它总是呈现为 Times New Roman。我还尝试将文本包装在 Typography 组件中并应用类覆盖,但这也不起作用。
这是我的按钮组件:
<Button
variant="contained"
className={classes.sideBarButtons}
fullWidth
>
Some Text
</Button>
这是我使用 makeStyles 覆盖的类:
sideBarButtons: {
height: "25%",
background: "#FF0000",
borderRadius: 0,
color: "white",
paddingTop: "2em",
paddingBottom: "2em",
fontFamily: 'Roboto',
},
【问题讨论】:
-
您尝试使用标签“important”覆盖现有类,例如:fontFamily: 'Roboto !important',
-
Button组件从何而来?
-
@JoshBirdwell 它来自 material-ui/core npm 包。 link