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

178
Views
Add a new color to Materail UI button with a custom theme

I have been using Materail UI v5 in my next js project with typescript.

theme.ts

import { createTheme, Theme } from "@mui/material/styles";
import { blue, orange, pink, purple, red, yellow } from "@mui/material/colors";

export const theme = createTheme({
  palette: {
    primary: {
      main: red[300],
    },
    success: {
      main: blue[200],
    },
    secondary: {
      main: yellow[200],
    },
  },
});

i made a component for button which is

import React from "react";
import { Button as BaseButton } from "@mui/material";
import {ButtonProps} from "@mui/material/Button"

export type IButton = ButtonProps | "qwer";

export const Button:  React.FC<IButton> = ({ ...rest }) => {
  return <BaseButton {...rest} />;
};

and then use it like

<Button
            type="submit"
            fullWidth
            variant="contained"
            color="secondary"   //primary or success
            className={classes.submit}
          >

but now lets say if i want to add a new color name to my theme how do i add this ?

tried with

export const theme = createTheme({
  palette: {
   primary: {
   main: red[300],
   },
   xyz:{
     qwe:red[500]
  },
});

and then

<Button
            type="submit"
            fullWidth
            variant="contained"
            color={theme.palette.xyz.qwe}
            className={classes.submit}
          >

it throws error

Type '{ primary: { main: "#e57373"; }; xyz: { qwe: "#e57373"; }; }' is not assignable to type 'PaletteOptions'.

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!