小智 8
假设您正在使用material-ui-next,则可以在createMuiTheme中使用覆盖.
import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles';
const theme = createMuiTheme({
overrides: {
MuiInput: {
underline: {
'&:before': { //underline color when textfield is inactive
backgroundColor: 'red',
},
'&:hover:not($disabled):before': { //underline color when hovered
backgroundColor: 'green',
},
}
}
}
Run Code Online (Sandbox Code Playgroud)
});
然后用MuiThemeProvider包装你的应用程序
ReactDOM.render(
<MuiThemeProvider theme={theme}>
<Root />
</MuiThemeProvider>,
document.getElementById('root')
);
Run Code Online (Sandbox Code Playgroud)
它将覆盖所有TextField material-ui组件的下划线颜色.如果您只需要为一个TextField更改颜色,请使用https://material-ui-next.com/customization/overrides/#1-specific-variation-for-a-one-time-situation
| 归档时间: |
|
| 查看次数: |
4203 次 |
| 最近记录: |