question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

notchedOutline class in OutlinedInput doesn't override

See original GitHub issue
  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 🤔

According to the documentation, I should be able to override the notchedOutline CSS by using classes:{{ notchedOutline: classes.foo }}.

Current Behavior 😯

This doesn’t seem to be working.

Steps to Reproduce 🕹

  1. Create a css class for borderColor.
const useStyles= makeStyles((theme) => ({
notched: {
  paddingLeft: theme.spacing(6.5),
  borderColor: "green",
  "&:hover": "green",
  "&:focused": "green",
}
}})

  1. Create a component that contains an outlined input.
export const InputComponent = () => {
  const classes = uesStyles();
  return (
    <FormControl variant="outlined">
      <InputLabel
        variant="outlined"
        htmlFor="input"
      >
        Input Label Text
      </InputLabel>
      <OutlinedInput
        id="input"
        labelWidth={100}
        classes={{ notchedOutline: classes.notched }}
      />
    </FormControl>
  );
};

The border color will not change and no padding will be applied.

Also, from the implementation it seems I should be able to override it by changing the root class, however this also doesn’t work.

Context 🔦

I have an onChange prop that determines if the input is valid. If it’s valid, I want the border color to change to green. I also have an onSubmit prop on my form that also determines if the input is invalid, and if it’s invalid then it changes the border color to red. Otherwise if the input is invalid but the user has not submitted the form, the border color should be the default color (theme.palette.primary.main).

I also have a startAdornment and need to move the notch further right, so I need to increase paddingLeft (I have already handled the label transition).

Your Environment 🌎

Tech Version
Material-UI 4.0.0-alpha.8
React 16.8.6
Browser Chrome
TypeScript 3.4.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ryancogswellcommented, Apr 30, 2019

Please see my answer here: https://stackoverflow.com/questions/54325908/change-outline-for-outlinedinput-with-react-material-ui/54331012#54331012

Here’s a modified version of my example in that answer that shows doing a green border: https://codesandbox.io/s/vx057jo47

If after this, you still have difficulty with the padding portion, I recommend creating a StackOverflow question that includes a version of your code with the input adornment and explains what the desired look is.

0reactions
support[bot]commented, Apr 30, 2019

👋 Thanks for using Material-UI!

We use the issue tracker exclusively for bug reports and feature requests, however, this issue appears to be a support request or question. Please ask on StackOverflow where the community will do their best to help. There is a “material-ui” tag that you can use to tag your question.

If you would like to link from here to your question on SO, it will help others find it. If your issues is confirmed as a bug, you are welcome to reopen the issue using the issue template.

Read more comments on GitHub >

github_iconTop Results From Across the Web

notchedOutline class in OutlinedInput doesn't override #15524
According to the documentation, I should be able to override the notchedOutline CSS by using classes:{{ notchedOutline: classes.foo }} . Current ...
Read more >
Change outline for OutlinedInput with React material-ui
The key to understanding how to override these styles is to look at how they are defined in the Material-UI source code.
Read more >
OutlinedInput API - Material UI - MUI
You can override the style of the component using one of these customization options: With a global class name. With a rule name...
Read more >
How to change outline color of Material UI React input ...
Coding example for the question How to change outline color of Material UI React input ... outlinedInput, focused: classes.focused, notchedOutline: classes.
Read more >
How to Change MUI TextField's Border Color (Hover, Focus ...
Second, notice that there is a built in class called notchedOutline in the InputProps API that Material UI intends for us to target....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found