How to modify material UI datagrid checkbox icon?

Viewed 1920
2 Answers

You need to use the slots api to override components in the Material UI DataGrid library.

You should include the code in your question so others can benefit. You have this:

export default function DataTable() {
  return (
    <div style={{ height: 400, width: "100%" }}>
      <Checkbox />
      <DataGrid
        rows={rows}
        columns={columns}
        pageSize={5}
        rowsPerPageOptions={[5]}
        checkboxSelection
      />
    </div>
  );
}

Which just renders a round <Checkbox/> from your library above the <DataGrid/>. If you instead pass the <Checkbox/> to the component prop it will use that instead.

export default function DataTable() {
  return (
    <div style={{ height: 400, width: "100%" }}>
      <DataGrid
        components={{
          Checkbox: Checkbox,
        }}
        rows={rows}
        columns={columns}
        pageSize={5}
        rowsPerPageOptions={[5]}
        checkboxSelection
      />
    </div>
  );
}
Related