Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

material ui next dialog textfield underline color

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

like image 732
Alexei Rodriguez Avatar asked Jan 03 '23 21:01

Alexei Rodriguez


1 Answers

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

like image 60
Rinat Rezyapov Avatar answered Jan 13 '23 20:01

Rinat Rezyapov