Theme palette action selected color is not working in MUI version 5
See original GitHub issueWhen creating a custom theme, the palette.action.select color property is not working. The other action color properties are working great.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
The select color on a dropdown select component is not working.
The default theme color is used instead.
Expected Behavior 🤔
The color on a selected dropdown menu item should be set.
Steps to Reproduce 🕹
See this code sample: https://codesandbox.io/s/palette-select-demo2-6ql8p?file=/src/Demo.tsx
import * as React from "react";
import { Box,InputLabel, MenuItem, FormControl, Select } from "@material-ui/core";
import { createTheme, ThemeProvider } from "@mui/material/styles";
import { red } from "@mui/material/colors";
const theme = createTheme({
palette: {
action: {
select: red[500],
},
},
});
export default function Demo() {
const [age, setAge] = React.useState('');
const handleChange = (event) => {
setAge(event.target.value);
};
return (
<ThemeProvider theme={theme}>
<Box sx={{ minWidth: 120 }}>
<FormControl fullWidth>
<InputLabel id="demo-simple-select-label">Age</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={age}
label="Age"
onChange={handleChange}
>
<MenuItem value={10}>Ten</MenuItem>
<MenuItem value={20}>Twenty</MenuItem>
<MenuItem value={30}>Thirty</MenuItem>
</Select>
</FormControl>
</Box>
</ThemeProvider>
);
}
Your Environment 🌎
Edge and Chrome browsers on Windows 10.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Palette - Material UI - MUI
The palette enables you to modify the color of the components to suit your brand. Palette colors. The theme exposes the following palette...
Read more >MUI component received wrong theme color through SX ...
I just migrated my material UI version from 4 to 5. Everything went well, but now I have this strange bug: Everywhere else...
Read more >Theming with React and MUI - Welcome, Developer
Learn how to create custom themes to React app using MUI. ... is to add a couple of buttons to the page so...
Read more >Extend Material-UI theme in TypeScript - In Plain English
The problem of Material-UI theme; Extend Material-UI theme in TypeScript; Implement ... You normally assign one color to one palette option.
Read more >MUI Themes Fully-Featured with MUI v5 - NetworkSynapse
Since MUI v5, themes provide lots of new possibilities. We look at many new ways to ... Lastly, our action object handles all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am trying to adjust
theme.palette.action.selectedOpacity
andtheme.palette.action.hoverOpacity
but it seems hit or miss… For example, it affects Buttons with variantsecondary
but notprimary
? It also seems to have different effects if I set the primary color inmain
versuslight
ordark
. What istheme.vars
This is clearly a regression. MUI should be usable for design systems other than material, including ones that use secondary colors on list items.
At a minimum, it’s obviously wrong that there’s an item that can be specfied (selected) that changes nothing at all about the appearance of the theme.