how do i get rid of striped styling for table rows
Unfortunately it does not have a feature about row styling. But i can add it. It would be usefull feature.
If your requirement is urgent you can override Row completely.
https://mbrn.github.io/material-table/#/docz-examples-10-example-component-overriding
Hi @TimCodes ,
I added rowStyle feature to options. You can set a style object directly or return it with a function that takes rowData as parameter.
Example:
<MaterialTable
columns={[
{ title: 'Ad谋', field: 'name' },
{ title: 'Soyad谋', field: 'surname' },
{ title: 'Do臒um Y谋l谋', field: 'birthYear', type: 'numeric' },
{ title: 'Do臒um Yeri', field: 'birthCity', lookup: { 34: '陌stanbul', 63: '艦anl谋urfa' } }
]}
data={this.state.data}
title="Demo Title"
options={{
//rowStyle: { backgroundColor: 'green'},
rowStyle: rowData => {
if(rowData.name === "Mehmet") {
return {backgroundColor: 'yellow'};
}
return {};
}
}}
/>
This will be in version 1.12.0
I have the opposite problem --- rows are not striped, but I would like them to be.
Is there an options such as ...
row: {
'&:nth-of-type(odd)': {
backgroundColor: theme.palette.background.default,
},
OR
rowStyle: rowData => ({
backgroundColor: rowIndex % 2 === 0 ? "#EEE" : "#FFF",
}),
When I use the following, it seems to reference the original order of the data instead of the order of the rows as currently displayed :
rowStyle: rowData => ({
backgroundColor: rowData.tableData.id % 2 === 0 ? "#EEE" : "#FFF",
}),
Hi @gxwheel152 ,
I will add stripeRows to options asap.
@mbrn How do we change the hover color for the rows?
@mbrn have you been finished stripeRows option? I have been waiting for that update for sometime now
@mbrn How do we change the hover color for the rows?
You can do hover with css directly:
tbody.MuiTableBody-root > tr:hover {
background-color: #efefef;
}
And as for stripes:
tbody.MuiTableBody-root >:nth-of-type(2n)
{
background-color: #fafafa;
}
Hi, I want to add a backgroundColor fading out effect on newly added row, how can I achieve this?
I tried this, but it didn't work.
rowStyle: ()=>{
let color ='#FFF';
setTimeout(function(){color='#EEE'},2000)
return {backgroundColor: color}
}
This rowStyle does not change actions cell
Most helpful comment
Hi @TimCodes ,
I added rowStyle feature to options. You can set a style object directly or return it with a function that takes rowData as parameter.
Example:
This will be in version 1.12.0