如何在Material-ui中删除表格中单元格之间的线条

piz*_*zae 7 html css reactjs material-ui

我尝试编辑各种 css 和元素,但仍然无法让线条消失。如何使 Material-UI 中 Table 元素的行之间的线条消失?https://material-ui.com/components/tables/#tables

Nea*_*arl 42

如果您使用的是MUI v5,则可以使用这些sx道具。新的 MUI 版本还添加了tableCellClasses对象来帮助您以类型安全的方式引用组件 CSS className,而不是使用硬编码字符串"MuiTableCell-root"

import Table from "@mui/material/Table";
import TableCell, { tableCellClasses } from "@mui/material/TableCell";
Run Code Online (Sandbox Code Playgroud)
<Table
  sx={{
    [`& .${tableCellClasses.root}`]: {
      borderBottom: "none"
    }
  }}
>
Run Code Online (Sandbox Code Playgroud)

现场演示

编辑 57325232/如何删除材料 UI 中的表格中的单元格之间的线

  • @SomeoneSpecial 每个 MUI 组件都有一个 `[component]Classes` const。[此处](https://mui.com/guides/migration-v4/#replace-nested-classes-selectors-with-global-class-names)简要提到了这一点。 (2认同)

Rya*_*ell 21

正如 Soothran 在评论中提到的,这是由TableCell. 下面是一种自定义方法。

import MuiTableCell from "@material-ui/core/TableCell";

const TableCell = withStyles({
  root: {
    borderBottom: "none"
  }
})(MuiTableCell);
Run Code Online (Sandbox Code Playgroud)

编辑表无行


uns*_*dev 10

要删除特定表格单元格的边框线,请使用:

<TableCell sx={{ borderBottom: "none" }}>
  {/* ... */}
</TableCell>
Run Code Online (Sandbox Code Playgroud)


小智 7

要从特定 TableRow 中删除边框,您可以使用:

sx={{ "& td": { border: 0 } }}
Run Code Online (Sandbox Code Playgroud)