Below is an example showing how to customize the focus appearance of Select
.
You can find some explanation about the underline customization in my answer here: How do I custom style the underline of Material-UI without using theme?
import React from "react";
import PropTypes from "prop-types";
import { withStyles } from "@material-ui/core/styles";
import Input from "@material-ui/core/Input";
import InputLabel from "@material-ui/core/InputLabel";
import MenuItem from "@material-ui/core/MenuItem";
import FormControl from "@material-ui/core/FormControl";
import Select from "@material-ui/core/Select";
const styles = theme => ({
formControl: {
margin: theme.spacing.unit,
minWidth: 120
},
select: {
"&:focus": {
backgroundColor: "white"
}
},
selectInput: {
"&:hover:not($disabled):not($focused):not($error):before": {
borderBottomWidth: 1
},
"&:after": {
borderBottomWidth: 1
}
},
disabled: {},
focused: {},
error: {}
});
class SimpleSelect extends React.Component {
state = {
age: ""
};
handleChange = event => {
this.setState({ [event.target.name]: event.target.value });
};
render() {
const { classes } = this.props;
const selectInputClasses = {
root: classes.selectInput,
disabled: classes.disabled,
focused: classes.focused,
error: classes.error
};
return (
<FormControl className={classes.formControl}>
<InputLabel htmlFor="age-simple">Age</InputLabel>
<Select
value={this.state.age}
onChange={this.handleChange}
input={<Input classes={selectInputClasses} />}
inputProps={{
name: "age",
id: "age-simple",
classes: { select: classes.select }
}}
>
<MenuItem value="">
<em>None</em>
</MenuItem>
<MenuItem value={10}>Ten</MenuItem>
<MenuItem value={20}>Twenty</MenuItem>
<MenuItem value={30}>Thirty</MenuItem>
</Select>
</FormControl>
);
}
}
SimpleSelect.propTypes = {
classes: PropTypes.object.isRequired
};
export default withStyles(styles)(SimpleSelect);