Material ui 更改TextField材质UI v1的悬停颜色
我无法通过重写类名来更改文本字段的onHover颜色。我该怎么做Material ui 更改TextField材质UI v1的悬停颜色,material-ui,Material Ui,我无法通过重写类名来更改文本字段的onHover颜色。我该怎么做 我使用的是MaterialUIV1:TextField是使用组件实现的,该组件公开了一个名为underline的类作为其CSS API的一部分。以下是该类的当前定义: 要执行此操作,您需要使用其InputProps属性通过TextField传递它们。下面是我将下划线颜色更改为绿色的示例: // define a class that will be used to modify the underline class const
我使用的是MaterialUIV1:TextField是使用组件实现的,该组件公开了一个名为underline的类作为其CSS API的一部分。以下是该类的当前定义: 要执行此操作,您需要使用其InputProps属性通过TextField传递它们。下面是我将下划线颜色更改为绿色的示例:
// define a class that will be used to modify the underline class
const styleSheet = createStyleSheet(theme => ({
greenUnderline: {
'&:before': {
backgroundColor: '#0f0',
},
},
}));
通过TextField的InputProps重写输入的underline类:
<TextField
id="uncontrolled"
label="Uncontrolled"
defaultValue="foo"
className={classes.textField}
margin="normal"
InputProps={{ classes: { underline: classes.greenUnderline } }}
/>
这可能不是您想要做的事情,但它应该让您开始。用类重写没有帮助。 它通过覆盖createMuiTheme中的MUIclass工作,如下所示
const theme = createMuiTheme({
overrides: {
MuiInput: {
underline: {
'&:hover:not($disabled):before': {
backgroundColor: 'rgba(0, 188, 212, 0.7)',
},
},
},
},
});
这对我很有用:
export const theme = createMuiTheme({
overrides:{
MuiFilledInput:{
root:{
"&:hover": {
backgroundColor: '#5dc2a6',
}
}
}
});
请添加您当前的相关代码。这不是编码问题,请参考此示例代码。自您发布后,此示例代码有了一些变化。我必须做:
&:hover:not($disabled):not($focused):not($error):在“:{borderBottomColor:#ffffff”,},
export const theme = createMuiTheme({
overrides:{
MuiFilledInput:{
root:{
"&:hover": {
backgroundColor: '#5dc2a6',
}
}
}
});