ReactJs 样式组件:设置表格单元格的字体粗细

问题描述 投票:0回答:1

使用 React 18 和最新的样式组件,如何设置 MUI 表格单元格的字体粗细?

这段代码获得了正确的颜色,但没有设置字体粗细。

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

<StyledTableCell>Enrollment Date</StyledTableCell>

reactjs material-ui styled-components mui-x
1个回答
0
投票

尝试类似:

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

可能的 CSS 类描述如下:https://mui.com/material-ui/api/table-cell/

© www.soinside.com 2019 - 2024. All rights reserved.