How can I change the header background color, font size and font color?
Add a header style on your column definition that you want to style:
{ title: '...', field: '...', headerStyle: {backgroundColor: 'red'}}
If you want to apply a style to all columns just add a header style to options.
Thanks! It works when adding the headerstyle per column.
I want to apply the style to all columns. It seems not working.
style={{
columns={[
{
title: 'Name',
render: rowData => rowData.name + ' ' + rowData.surname,
},
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
{
title: 'Birth Place',
field: 'birthCity',
lookup: { 34: '陌stanbul', 63: '艦anl谋urfa' },
},
{
title: 'Score',
field: 'successScore',
render: rowData => {
const score = rowData.successScore + '%'
const color = rowData.successScore > 70 ? '#4CAF50' : '#f44336'
return (
textAlign: 'left',
padding: 1,
color: 'white',
width: score,
backgroundColor: color,
height: 20,
}}
>
{score}
Use this:
<MaterialTable
...
options={{
headerStyle:{backgroundColor:'red'}
}}
/>
Thanks @mbrn!
Hi, do you know how to change the color of the title of the table?
/>
Hi, how to change the color of the icon?
Hi @mbrn, how i can change the background of the table?
Hi, do you know how to change the color of the title of the table?
Hi @betocolon23,
I did it using MuiThemeProvider to override default styling, as MuiTypography-h6 component is being used for the table title.
const theme = createMuiTheme({
overrides: {
MuiTypography: {
h6: {
fontWeight: 'bolder !important',
color: darken('#5CDB94', 0.15),
},
},
},
});
<ThemeProvider theme={theme}>
<MaterialTable
...
/>
</ThemeProvider>
other solution is component overriding
import MaterialTable, { MTableToolbar } from 'material-table';
<MaterialTable
components={{
Toolbar: props => (
<div style={{color: darken('#5CDB94', 0.15),}}>
<MTableToolbar {...props} />
</div>
)
}}
/>
Great!! Thanks
Is there any way to access MUI theme palette colors directly in the headerStyle prop? I want to set header color="primary". Would I need a custom override for this?
@alexanderkho here is how I did it:
import { makeStyles, useTheme } from "@material-ui/core/styles";
const theme = useTheme()
<MaterialTable
headerStyle: {
width: 26,
whiteSpace: 'nowrap',
textAlign: 'left',
flexDirection: 'row',
overflow: 'hidden',
textOverflow: 'ellipsis',
paddingLeft: 5,
paddingRight: 5,
backgroundColor: theme.palette.primary.table,
fontWeight: 'bold',
color: theme.palette.primary.main,
},
/>
Most helpful comment
Hi, do you know how to change the color of the title of the table?
title={this.props.title}
/>