【问题标题】:How can I change font size of pagination part in material table using react js?如何使用 react js 更改材料表中分页部分的字体大小?
【发布时间】:2020-05-10 12:40:03
【问题描述】:

我想增加素材表页脚分页部分的字体大小。

在下图中,我可以使用以下代码更改每页行的字体大小

[1]: https://i.stack.imgur.com/cjNmp.png

components={{
    Pagination: props => (
      <TablePagination
        {...props}

        SelectProps={{
          style:{
            fontSize: 20
          }
        }}
      />
    )
  }}

但仍无法更改整个下划线部分的增大尺寸

【问题讨论】:

    标签: reactjs pagination components material-ui material-table


    【解决方案1】:

    我使用两种不同的方法为两个标题区域设置样式:一种通过工具栏样式,另一种直接:

    results per page 组件中有两个部分,默认为p

    import makeStyles from "@material-ui/core/styles/makeStyles";
    const useStyles = makeStyles({
      caption: {
        color: "green",
        padding: 8,
        border: "1px dashed grey",
        fontSize: "0.875rem"
      },
      toolbar: {
        "& > p:nth-of-type(2)": {
          fontSize: "1.25rem",
          color: "red",
          fontWeight: 600
        }
      }
    });
    
    // then later
    
    const classes = useStyles();
    <TablePagination 
          // ...
          classes={{
            toolbar: classes.toolbar,
            caption: classes.caption
          }}
        />
    

    这是codesandbox demo

    【讨论】:

    • 这段代码在函数式编码中正常工作,但我正在使用类,所以有什么建议吗?
    • 是的,const StyledTablePagination = withStyles(stylesObject)(TablePagination)
    • withStyles 是一个用于编写样式的 Material-ui HOC
    猜你喜欢
    • 2020-09-19
    • 2019-01-18
    • 2016-07-21
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    • 2018-08-07
    • 2020-01-07
    • 2021-10-30
    相关资源
    最近更新 更多