Material ui 覆盖大、中、小按钮标签,材质界面
我尝试只使用主题中的覆盖来设置按钮的样式。我可以使用sizeLarge和sizeSmall来定位相应的按钮,但是没有sizeMedium。目标根被MuiButton标签覆盖,目标标签覆盖SizeMail和sizeLarge 这是密码Material ui 覆盖大、中、小按钮标签,材质界面,material-ui,Material Ui,我尝试只使用主题中的覆盖来设置按钮的样式。我可以使用sizeLarge和sizeSmall来定位相应的按钮,但是没有sizeMedium。目标根被MuiButton标签覆盖,目标标签覆盖SizeMail和sizeLarge 这是密码 <Button color="primary" variant="contained" size="large"> Button Name - Large </Button> &
<Button color="primary" variant="contained" size="large">
Button Name - Large
</Button>
<Button color="primary" variant="contained">
Button Name - Medium
</Button>
<Button color="primary" variant="contained" size="small">
Button Name - Small
</Button>
您仍然可以引用
标签
规则名称,但对于根
,请指定CSS规则不应用于.MuiButton sizeLarge
&.MuiButton sizeSmall
const theme=createMuiTheme({
覆盖:{
穆伊布顿:{
根:{
“&:not($sizeLarge):not($sizeSmall)$label”:{
字体:“普通700 0.875rem/1.6875rem开放式SAN”,
颜色:“绿色”
}
},
尺寸:{
“&$label”:{
字体:“普通700 0.9375rem/1.6875rem开放式SAN”,
}
},
大小球:{
“&$label”:{
字体:“正常700 0.8125rem/1.6875rem开放式SAN”
}
}
}
}
});
函数应用程序(){
返回(
按钮名称-大
按钮名称-中等
按钮名称-小
);
}
render(,document.getElementById(“根”))代码>
常量{CreateMuiteme,Button,ThemeProvider}=MaterialUI;
import { createMuiTheme } from "@material-ui/core/styles";
import "typeface-poppins";
import "typeface-open-sans";
export const theme = createMuiTheme({
overrides: {
// Style sheet name ⚛️
MuiButton: {
// Name of the rule
// gets overwritten by label styles
// if label, overwrites below styles
root: {
// Some CSS
font: "normal normal 700 0.875rem/1.6875rem Open Sans",
color: "green",
},
sizeLarge: {
// Some CSS
font: "normal normal 700 0.9375rem/1.6875rem Open Sans",
},
sizeSmall: {
font: "normal normal 700 0.8125rem/1.6875rem Open Sans",
},
},
},
});