Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
MUI DataGrid gray header on custom column

I recently migrated from MUI v4 to v5 and I had a DataGrid with a style that looked like this:

const useStyles = makeStyles((theme) => ({
    root: {
        flexGrow: 1,
        "& .header-fix": {
            backgroundColor: 'rgba(255, 255, 255, 0)',
        },
    },
}));

const dataGridColumns = [
        { field: 'id', hide: true },
        { field: 'name', headerName: 'name', width: 200 },
        {
            field: 'actions',
            headerName: 'actions',
            headerClassName: "header-fix",
            disableColumnMenu: true,
            width: 150,
            disableClickEventBubbling: true,
            renderCell: (params) => {
                const id = params.row.id;
                return (
                    <div>
                        <Tooltip title='Edit'>
                            <IconButton aria-label="edit" onClick={() => editItem(id)}> <EditIcon /> </IconButton>
                        </Tooltip>
                        <Tooltip title='Delete'>
                            <IconButton aria-label="delete" onClick={() => deleteItem(id)}> <DeleteIcon /> </IconButton>
                        </Tooltip>
                    </div>
                )
            }
        }
    ];

This worked and the background color for the actions was indeed white. However when I migrated to MUI v5, I see a gray background. I tried to use styled components like this:

const StyledDataGrid = styled(DataGrid)({
    ".header-fix": { backgroundColor: "rgba(255, 255, 255, 0)"}
});

But now the "header-fix" class doesn't even appear. If I set it like this:

const StyledDataGrid = styled(DataGrid)({
    "& .header-fix": { backgroundColor: "rgba(255, 255, 255, 0)"}
});

Then it appears but it is crossed out, like you can see in the screenshot:

Screenshot showing the header-fix class crossed out

Setting the !important property doesn't work either. I am running out of ideas. What am I doing wrong? Why this used to work in v4 but not in v5?

EDIT: this does not work either:

const StyledDataGrid = styled(DataGrid)({
    "& .header-fix": { backgroundColor: "rgba(255, 255, 255, 0); !important" },
    "& .MuiDataGrid-columnHeader--moving": { backgroundColor: "rgba(255, 255, 255, 0); !important" }
});
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda