5

I have been using material-table in one of my projects.

While I am able to change the style ( font-size, color) of the user defined columns, I am not able to do so for the "Actions" column.

I am specially interested in changing the font-size.

Same issue with the pagenation: I need to change its font-size however it seems there is no option available.

Please take an example from :

https://material-ui.com/components/tables/#complementary-projects

Deep
  • 528
  • 3
  • 12
  • 27
  • Are you sure your code is similar to the example? any additional component? – Alex Jan 17 '20 at 04:57
  • @Alex yes only this component, you can see the code here:https://material-table.com/#/docs/features/editable – Deep Jan 18 '20 at 14:04

2 Answers2

11

For pagination, you should override pagination component.issue, documentation

const useStyles = makeStyles({
  root: {
    backgroundColor: "blue",
    color: "green"
  },
  toolbar: {
    backgroundColor: "white"
  },
  caption: {
    color: "red",
    fontSize: "20px"
  },
  selectIcon: {
    color: "green"
  },
  select: {
    color: "green",
    fontSize: "20px"
  },
  actions: {
    color: "blue"
  }
});
...
 <MaterialTable
    .....
    components={{
            Pagination: props => (
              console.log(props),
              (
                <TablePagination
             {props.labelDisplayedRows(row)}</div>}
                  component="div"
                  colSpan={props.colSpan}
                  count={props.count}
                  rowsPerPage={props.rowsPerPage}
                  page={props.page}
                  onChangePage={props.onChangePage}
                  onChangeRowsPerPage={this.onChangeRowsPerPage}
                  classes={{
                    root: classes.root,
                    toolbar: classes.toolbar,
                    caption: classes.caption,
                    selectIcon: classes.selectIcon,
                    select: classes.select,
                    actions: classes.actions
                  }}
                />
              )
            )
          }}

For for the "Actions" column, I've used actions property

 actions={[
        {
          icon: "save",
          iconProps: { style: { fontSize: "14px", color: "green" } },
          tooltip: "Save User",
          onClick: (event, rowData) => alert("You saved " + rowData.name)
        }
      ]}


have look at this codesandbox,would be helpful.

Alex
  • 3,941
  • 1
  • 17
  • 24
  • Thanks Alex...I had a look at the codesandbox and it is inline with my expectations.Let me try this out and get back to you. – Deep Jan 20 '20 at 16:45
  • Alex, I am having an issue when I use cellStyle instead of actionCellStyle, IN codesendbox it worked but when I copy it to my project it is not working.Issue is only with cellStyle on my code. Any idea what can be wrong here? – Deep Feb 06 '20 at 13:40
  • @Deep, please attach your codesendbox link , I will have look. – Alex Feb 06 '20 at 19:48
0

if you want to stick to the user-defined theme then use props from icon api of material-ui.

actions={[
    {
      icon: "save",
      iconProps: {  fontSize: "small", color: "primary"  },
      tooltip: "Save User",
      onClick: (event, rowData) => alert("You saved " + rowData.name)
    }
  ]}
YaSh Chaudhary
  • 2,605
  • 8
  • 37
  • 74