javascript - React Material-UI - 样式标签
问题描述
我对反应很陌生,我已经在这几个小时了,没有太多运气。
我正在尝试设置标签的样式,以便下划线颜色为白色:
我怀疑这与覆盖类有关:指标,但我不完全确定它是如何/为什么起作用的。
为了清楚起见,我附上了我的代码。
import React, {Component} from "react"
import AppBar from "@material-ui/core/AppBar/AppBar";
import Tabs from "@material-ui/core/Tabs/Tabs";
import Tab from "@material-ui/core/Tab/Tab";
import withStyles from "@material-ui/core/es/styles/withStyles";
const styles = {
AppBar: {
background: 'transparent',
boxShadow: 'none'
},
Indicator:{
ripple:{
color: 'blue'
},
backgroundColor: 'white',
}
};
class NavBar extends Component {
render() {
return (
<AppBar style={styles.AppBar}>
<Tabs classes={{ indicator: styles.Indicator}} centered value={0}>
<Tab label="Fairness"/>
<Tab label="Community" />
<Tab label="Referrals" />
<Tab label="How To Play" />
</Tabs>
</AppBar>
)
}
}
export default withStyles(styles)(NavBar);
对此的任何指导/解释将不胜感激。
解决方案
对于 Material-UI 选项卡,indicatorColor 是一个enum: 'secondary' | 'primary'
,但您可以使用或覆盖它。有关此主题的进一步讨论,请参阅选项卡 API和自定义选项卡演示,或mui-org/material-ui/#11085。classes
TabIndicatorProps
这是您的示例,它覆盖了白色下划线颜色的indicator
withclasses
并显示了如何禁用波纹(注意不同的withStyles
导入语法):
import React, { Component } from "react";
import AppBar from "@material-ui/core/AppBar/AppBar";
import Tabs from "@material-ui/core/Tabs/Tabs";
import Tab from "@material-ui/core/Tab/Tab";
import { withStyles } from "@material-ui/core/styles/";
const styles = theme => ({
indicator: {
backgroundColor: "white"
}
});
class NavBar extends Component {
render() {
const { classes } = this.props;
return (
<AppBar style={styles.AppBar}>
<Tabs classes={{ indicator: classes.indicator }} centered value={0}>
<Tab disableRipple label="Fairness" />
<Tab disableRipple label="Community" />
<Tab label="Referrals" />
<Tab label="How To Play" />
</Tabs>
</AppBar>
);
}
}
export default withStyles(styles)(NavBar);
推荐阅读
- powershell - 如何取此写入输出的第 3 行
- excel - 如何制作具有两个变量的数组公式
- deep-learning - pytorch中如何共享两个模型的共同部分?
- javascript - 如何使用 javascript 隐藏 jinja 自动生成的表单?
- python - 为什么 GnuPG 解密速度这么低
- java - 无法找到请求目标的有效认证路径,想法
- java - Spring 外部资源
- azure - 收到电子邮件后创建 Azure 板卡
- c# - .NET Core 3.0 迁移错误 IAsyncEnumerable
System.Interactive.Async 和 System.Runtime 中都存在 - paypal - 减少 Paypal 结帐期间的重定向次数