material-table
material-table copied to clipboard
Change color of check icons
Change color of check icons
Excepted I excepted icons in boolean type to change color
To Reproduce TableIcons.js
...
Check: forwardRef((props, ref) => (
<Check style={{ color: "#008000" }} {...props} ref={ref} />
)),
...
index.js
...
<MaterialTable
data={data}
columns={columns}
title="Starter Template"
icons={tableIcons}
/>
...
Here the icons before the table are colored but not in the table
StackBlitz https://stackblitz.com/edit/material-table-starter-template-c2mqgj?file=index.js
Try this:
const columns = [
{ title: "Id", field: "id" },
{ title: "Word", field: "word" },
{ title: "Boolean", field: "boolean", type: "boolean",
cellStyle: (e, rowData) => {
if (!rowData.boolean) {
return { color: "red" };
} else return {color: "green"}
},
}
];

credits should go to: https://stackoverflow.com/questions/59150774/how-to-conditionally-style-reactjs-material-table-cell-based-on-cell-values