Search code examples
reactjspaginationcomponentsmaterial-uimaterial-table

How can I change font size of pagination part in material table using react js?


I want to increase the font size for the pagination part of the material table footer.

In the below image, I am able to change the font size of rows per page with the below code

[1]: https://i.sstatic.net/cjNmp.png

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

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

but still unable to change increase size of the whole underlined part


Solution

  • I styled both caption area using two different methods: One via toolbar styles and the other directly:

    There is two parts in the results per page component and are a p by default

    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
          }}
        />
    

    Here is a codesandbox demo