Skip to content

MUI v7 color palette extension problem with TypeScript when using new colors on a Button #45787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CzechCoder opened this issue Apr 1, 2025 · 1 comment
Labels
component: button This is the name of the generic UI component, not the React module! typescript

Comments

@CzechCoder
Copy link

CzechCoder commented Apr 1, 2025

I created a new color palette I want to use on a Button as in accordance to the documentation:

const theme = createTheme({
palette: {
customRed: {
main: "#ff1100",
light: "#f75348",
dark: "#ba1f14",
contrastText: "#FFF",
},
}
})

Then extended TypeScript declarations:

declare module "@mui/material/styles" {
interface Palette {
customRed: Palette["primary"];
}

interface PaletteOptions {
customRed?: PaletteOptions["primary"];
}

But then I get a TS error when using the new color palette on a Button (Type "customRed" is not assignable to type):

Button

It should work and it used to work for me in the past, but now it doesn't. Any ideas on how to expand my color palette for buttons?

Search keywords:

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 1, 2025
@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 1, 2025
Copy link

github-actions bot commented Apr 1, 2025

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@zannager zannager added component: button This is the name of the generic UI component, not the React module! typescript labels Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: button This is the name of the generic UI component, not the React module! typescript
Projects
None yet
Development

No branches or pull requests

2 participants