我无法通过覆盖类名来更改TextField的onHover颜色。我该如何做?
我正在使用Material UI v1:https://github.com/callemall/material-ui/tree/v1-beta
我正在使用Material UI v1:https://github.com/callemall/material-ui/tree/v1-beta
使用类进行覆盖无法解决问题。 只有通过在createMuiTheme中覆盖MUIclass才能解决问题,代码如下。
const theme = createMuiTheme({
overrides: {
MuiInput: {
underline: {
'&:hover:not($disabled):before': {
backgroundColor: 'rgba(0, 188, 212, 0.7)',
},
},
},
},
});
&:hover:not($disabled):not($focused):not($error):before': { borderBottomColor: "#ffffff", },
- Braden HoltTextField使用Input组件实现,该组件公开了一个名为underline的类作为其CSS API的一部分。以下是Input source中此类的当前定义:
underline: {
paddingBottom: 2,
'&:before': {
backgroundColor: theme.palette.input.bottomLine,
left: 0,
bottom: 0,
// Doing the other way around crash on IE11 "''" https://github.com/cssinjs/jss/issues/242
content: '""',
height: 1,
position: 'absolute',
right: 0,
transition: theme.transitions.create('backgroundColor', {
duration: theme.transitions.duration.shorter,
easing: theme.transitions.easing.ease,
}),
},
'&:hover:not($disabled):before': {
backgroundColor: theme.palette.text.primary,
height: 2,
},
'&$disabled:before': {
background: 'transparent',
backgroundImage: `linear-gradient(to right, ${theme.palette.input
.bottomLine} 33%, transparent 0%)`,
backgroundPosition: 'left top',
backgroundRepeat: 'repeat-x',
backgroundSize: '5px 1px',
},
},
// define a class that will be used to modify the underline class
const styleSheet = createStyleSheet(theme => ({
greenUnderline: {
'&:before': {
backgroundColor: '#0f0',
},
},
}));
<TextField
id="uncontrolled"
label="Uncontrolled"
defaultValue="foo"
className={classes.textField}
margin="normal"
InputProps={{ classes: { underline: classes.greenUnderline } }}
/>