微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

材料UI分页组件文本颜色为灰

如何解决材料UI分页组件文本颜色为灰

我正在使用 Material UI 的分页组件,并且希望组件的文本部分为灰色。我想要的颜色是白色的动作按钮和灰色的文本部分。有什么办法可以让我决定文本部分的颜色吗?本质上希望文本像照片中的左操作箭头一样是灰色的。

enter image description here

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>
  );
}

现场演示

Edit late-field-s59ox

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?