I want to alter the style of the SelectInput. I'm using a class based component. I set it up this way:
const QuoteListStyle = {
color: "#eceff1",
borderBottom: "1px solid #90caf9",
"&:hover:not($disabled):not($focused):not($error) $underline": {
borderBottom: "2px solid #90caf9"
},
width: "196px",
marginTop: "1rem"
};
Then in the render I have this section with the Select:
<FormControl>
<Select
style={QuoteListStyle}
value={this.state.quoteListName}
onChange={this.handleChange}
displayEmpty={true}
renderValue={
this.state.quoteListName > 0
? undefined
: () => <em>{this.state.quoteListName}</em>
}
>
<MenuItem value="" disabled>
<em>Select a Quote List</em>
</MenuItem>
{data.me.quoteList.map(item => {
return (
<MenuItem value={item.name} key={item.name}>
{item.name}
</MenuItem>
);
})}
</Select>
</FormControl>
I'm using the basic Select component that only has an underline. I want to change the color and size of the underline. I looked here in the source:
https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Select/SelectInput.js
What do I look for to control the underline?
I am seeing the underline that I want when the component loads. The hover is not working. After an item from the Select is chosen, I see my style on top but the default style is below and I can see some of that color.
I would be ok using overrides for this. Here's my theme code:
const theme = createMuiTheme({
palette: {
primary: {
main: "#90caf9",
contrastText: "#f5f5f5"
},
secondary: {
main: "#19857b"
},
error: {
main: "#f44336"
},
background: {
default: "#102027",
paper: "#37474f"
},
text: {
primary: "#eceff1",
secondary: "#90caf9"
},
button: {
borderColor: "#90caf9"
}
},
overrides: {
MuiOutlinedInput: {
root: {
"& $notchedOutline": {
borderColor: "#90caf9"
},
"&:hover:not($disabled):not($focused):not($error) $notchedOutline": {
borderColor: "#90caf9",
borderWidth: 2
},
"&$focused $notchedOutline": {
borderColor: "#90caf9"
}
},
notchedOutline: {}
},
MuiSelect: {
icon: {
fill: "#90caf9"
}
}
}
});
export default theme;
I also looked in the devtools and found this:
<div class="MuiSelect-root MuiSelect-select MuiSelect-selectMenu MuiInputBase-input MuiInput-input MuiInputBase-inputSelect" aria-pressed="false" tabindex="0" role="button" aria-haspopup="true"><em>Tech</em></div>
I'm not sure how to use that to target what I want.
See Question&Answers more detail:
os