Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

307
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!