css - 材质ui分页组件文本颜色为灰色
问题描述
我正在使用 Material UI 的分页组件,并希望组件的文本部分为灰色。我想要的颜色是白色的动作按钮和灰色的文本部分。有什么办法可以让我决定文本部分的颜色吗?本质上希望文本像照片中的左操作箭头一样是灰色的。
import React from 'react';
import TablePagination from '@material-ui/core/TablePagination';
import PropTypes from 'prop-types';
import { withTheme, withStyles } from '@material-ui/core/styles';
const styles = theme => ({
root: {
flexShrink: 0,
color: theme.palette.common.white,
marginLeft: theme.spacing.unit * 2.5,
},
});
const PortfolioPagination = ({
numOfItems, rowsPerPage, page, handleChangePage, classes
}) => {
return (
<div >
<TablePagination
component="div"
className={classes.root}
count={numOfItems}
page={page}
onChangePage={handleChangePage}
rowsPerPageOptions={[]}
rowsPerPage={rowsPerPage} />
</div>
);
};
PortfolioPagination.defaultProps = {
};
PortfolioPagination.propTypes = {
classes: PropTypes.object.isRequired,
numOfItems: PropTypes.number.isRequired,
rowsPerPage: PropTypes.number.isRequired,
page: PropTypes.number.isRequired,
handleChangePage: PropTypes.func.isRequired,
};
export default withTheme()(withStyles(styles)(PortfolioPagination));
解决方案
我最近遇到了同样的问题,并通过使用组件的样式自定义点解决了它。这是一个例子:
import { TablePagination } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles((theme) => ({
color: {
color: "green"
},
leftIconButton: {
color: "blue !important"
},
rightIconButton: {
color: "red !important"
}
}));
export default function App() {
const classes = useStyles();
return (
<div className="App">
<TablePagination
classes={{
root: classes.color
}}
backIconButtonProps={{ className: classes.leftIconButton }}
nextIconButtonProps={{ className: classes.rightIconButton }}
rowsPerPageOptions={5}
component="div"
count={10}
rowsPerPage={5}
page={1}
onChangePage={() => {}}
onChangeRowsPerPage={() => {}}
/>{" "}
</div>
);
}
现场演示
推荐阅读
- reactjs - 如何使用组件中的本地状态更新 redux 状态
- jsp - 将带有单选按钮值的多行传递到下一页
- android - 图片未显示在推送通知中
- sqlite - 从 SQLITE 中的两列中选择不同的值
- neo4j - 如何有效地计算 Cypher 中两个节点之间的所有路径?
- .net-core - GetChangeFeedProcessorBuilder 回调第一次为空更改
- rest - @PathVariable 给出 400 Bad Request
- android - 如何在Android中以编程方式停止使用电子邮件输入类型的edittext自动建议
- javascript - 带有asp.net mvc的完整日历不显示事件
- string - 我正在使用 Java 通过在我的代码中动态生成查询来从弹性搜索中获取一些记录。查询需要一个字符串