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

114
Visualizações
My style made by makestyle material ui is overriden by something

What can i do to make my makestyles classes more important than default material ui style?

That's my code:

import { createTheme, ThemeProvider } from '@mui/material/styles';
import { makeStyles, createStyles } from '@mui/styles';

const customTheme = createTheme({
  palette: {
    primary:{
      main: '#303030',
    },        
  },
  
  components:{
    MuiButton:{
      styleOverrides: {            
        root: {
          '&:focus': {
            background: "#f00",
          },
          '&:hover': {
            background: "#f00",
          },
          '&::after': {
            content: '"xd"',
            color: 'blue',
          },
        },
        contained:{
          borderRadius:'50%',
        },
      },
      variants: [
        {
          props: { variant: 'dashed' },
          style: {
            textTransform: 'none',
            border: `2px dashed #000000`,
          },
        },
      ],
    },
  },
});

const useStyles = makeStyles((theme) =>
//I tried without createStyles too, no change
  createStyles({
    root: {
    },
    differentButton:{
      backgroundColor: 'green',
      fontSize: '30px',
      opacity: '80%',
    },
    //tak sie propsy przekazuje
    foo: (props) => ({
      backgroundColor: props.backgroundColor,
    }),
  }),
);

function App() {
  const classes = useStyles();

  return (
    <>
      <CssBaseline/>
  <Button className={classes.differentButton}>Different</Button>

      <RemoveButton variant="contained">Remove Button</RemoveButton>
      <ThemeProvider theme={customTheme}>
        <Button className={classes.differentButton}>Different</Button>
      </ThemeProvider>
    </>
  );
}

Its overrided by sth Its overrided by something (default material ui style i think so)

Does it means that with customizing material ui components i can't use makeStyles? I know that i can do that with styled() too but makeStyles way seems better to me.

Ps. I dont want to use !important everywhere hah

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There are several solutions.

You can use withStyles, mui v4

withStyles

Use emotion style by styled

styled

Also you can use !important in material-ui

about 4 years ago · Juan Pablo Isaza Relatório
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