material ui next dialog textfield underline color

可紊 提交于 2020-01-02 08:07:42

问题


How can I change the underline color of a textfield inside a dialog with my secondary palette color? I couldn't do it since the documentation it's quite confusing


回答1:


Assuming you are using material-ui-next, you can use overrides in 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',
        },
      }
    }
  }

});

Then wrap you app with MuiThemeProvider

ReactDOM.render(
 <MuiThemeProvider theme={theme}>
   <Root />
 </MuiThemeProvider>,
 document.getElementById('root')
);

It will overwrite underline color of all TextField material-ui components. If you need to change color only for one TextField, use https://material-ui-next.com/customization/overrides/#1-specific-variation-for-a-one-time-situation



来源:https://stackoverflow.com/questions/48489252/material-ui-next-dialog-textfield-underline-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!