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

308
Visualizações
Material ui emotion styles, reusable styles

Well I wonder, how would one create a reusable style for material ui? (emotion).

Normally a style can be written like:

import {styled, css, Theme} from "@mui/material";
import IconButton from '@mui/material/IconButton';
import MenuIcon from '@mui/icons-material/Menu';


const StyledMenuButton = styled(IconButton)(`
  margin-left: 16px;
  max-height: 48px;
`);

export const SomeComponent() {
    return <IconButton>
       <MenuIcon />
    </IconButton>
}

However I tried to make the style snippet reusable for multiple components:

import {styled, Theme} from "@mui/material";
import IconButton from '@mui/material/IconButton';
import MenuIcon from '@mui/icons-material/Menu';

const baseStyle = css`
    margin-left: 16px;
    max-height: 48px;
`;

const StyledMenuButton = styled(IconButton)(`${baseStyle}`);

export const SomeComponent() {
    return <StyledMenuButton>
       <MenuIcon />
    </StyledMenuButton>
}

And now the style won't load anymore? How to use reusable styles in emotion?

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