ReactJs Styled Components: Set Font Weight of Table Cell

91 Views Asked by At

Using React 18, and latest styledcomponents, how do I set the font weight for MUI Table Cell?

This code is getting the right color, but not setting font weight.

const StyledTableCell = styled(TableCell)({
  backgroundColor: "#99D9EA",
  fontWeight: "800",
});

<StyledTableCell>Enrollment Date</StyledTableCell>

enter image description here

1

There are 1 best solutions below

2
On BEST ANSWER

Try something like:

const StyledTableCell = styled(TableCell)({
  "& .MuiTableCell-head": {  // or "& .MuiTableCell-root" or "& .MuiTableCell-body" ...
    backgroundColor: "#99D9EA",   
    fontWeight: 800,
  }  
});   

Possible CSS classes are described here: https://mui.com/material-ui/api/table-cell/