所以我想将Material UI Select组件的文本,图标和下划线颜色从黑色更改为白色,如下所示:
由MenuItem实现的选项文本颜色默认情况下看起来不错,因为它们是白色的灰色:
我原来的documentation of Select并没有太大帮助,因为它没有说明我应该在类中覆盖哪个CSS类。
import React from "react";
import ReactDOM from "react-dom";
import { withStyles } from "@material-ui/core/styles";
import FormControl from "@material-ui/core/FormControl";
import Select from "@material-ui/core/Select";
import MenuItem from "@material-ui/core/MenuItem";
const styles = theme => ({
root: {
background: "blue",
backgroundColor: "blue"
}
});
const OPTIONS = {
A: "Option A",
B: "Option B"
};
class App extends React.Component {
state = {
option: OPTIONS.A
};
handleOptionChange = event => {
return this.setState({ option: event.target.value });
};
render() {
const { classes } = this.props;
return (
<div className={classes.root}>
<FormControl variant="outlined">
<Select
value={this.state.option}
onChange={this.handleOptionChange}
name="optionsDropdown"
>
<MenuItem value={OPTIONS.A}>{OPTIONS.A}</MenuItem>
<MenuItem value={OPTIONS.B}>{OPTIONS.B}</MenuItem>
</Select>
</FormControl>
</div>
);
}
}
const DemoApp = withStyles(styles)(App);
const rootElement = document.getElementById("root");
ReactDOM.render(<DemoApp />, rootElement);
答案 0 :(得分:0)
找到了一种方法,可以通过覆盖 root 和 icon 类:
theContacts.flat();
https://codesandbox.io/s/x3j9lz9z2o
唯一需要更改的是下划线颜色。