Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change outline color of Material UI React input component?

Tags:

People also ask

How do you put a border in material UI?

Material-UI Theme Overrides Theme overrides changed in MUI v5. I'll show code for both Material-UI v4 and MUI v5. To quickly add a border radius to all instances of a component, create a custom theme and add an overrides section. To create a custom theme, use the createMuiTheme hook.


I've searched high and low for an answer, in both the docs and other SO questions.

I'm using the createMuiTheme option in a separate JS file to override certain default styling, but am having a hard time understanding how the overrides option works.

Currently my button looks like this: enter image description here The code I've got to get this far looks like this:

const theme = createMuiTheme({
    ...other code,
    overrides: {
    MuiFormControlLabel: {
        focused: {
            color: '#4A90E2'
        }
    },
    MuiOutlinedInput: {
        focused: {
                border: '1px solid #4A90E2'
        },
        notchedOutline: {
            border: '1px solid #4A90E2'
        },
    },
    MuiFormLabel: {
        focused: {
            color: '1px solid #4A90E2'
        }
    }
}
)};

Then in my component, I'm using it as such:

import theme from './styles/ThemeStyles';
import { withStyles } from '@material-ui/core/styles';

class SignInForm extends Component {
render() {
    const { classes } = this.props;
    <form className={classes.container} noValidate autoComplete='off'>
        <TextField
            id="outlined-email-input"
            label="Email"
            className={classes.textField}
            type="email"
            name="email"
            autoComplete="email"
            margin="normal"
            variant="outlined"
        />
    </form>
}}

My question is, what am I missing to make my component look so funky? And in the future, how do I know what to target in the overrides option of the ThemeProvider so that I don't run into similar situations?