As seen here line, the color of the underline in the Input component is set to be dark on light theme and light on dark theme. It's not configurable though, so we can't change it via custom theme, only by overriding classes. You can however change all other colors using theme alone, which seems like an inconsistency.
I'd like to submit a PR changing this to some value from theme, but I'm not sure which one - default text colors don't match this particular underline.
The color for the underline should be taken from theme.
The color is hardcoded.
Link: https://codesandbox.io/s/8xv2k57ym8
I'd like to style it in some other way than overriding quite complex JSS classes every time.
| Tech | Version |
|--------------|---------|
| Material-UI | v3.6.1 |
| React | N/A |
| Browser | N/A |
| TypeScript | N/A |
| etc. | N/A |
@Co0sh What about?
const theme = createMuiTheme({
overrides: {
MuiInput: {
underline: {
"&:before": {
borderBottom: `1px solid ${color}`
}
}
}
}
});
Yes, it definitely works, but I guess my point is that this doesn't feel like a correct solution. Is there any reason to have the underline the way it is right now and not as I described?
@Co0sh What would be the correct solution?
The color for the underline should be taken from theme.
Now that I think of it, it might not be a good idea after all. Changing the underline color could be a breaking change for people with custom themes, unless it's put in its own variable and not computed out of some other colors.
Thanks for the help though, I'll use the override for now 馃憣
@Co0sh This is a problem we have been wrapping our head around for quite some time. Some alternatives:
Tinkering with the Input underline as well at the moment.
I'm getting rid of the scale transformation and I would like to have just a simple color transition on &:hover
and &$focused
. It feels a bit tedious to understand whether and how I should modify &:before
or &:after
not to mess with different state colors (like Mui-error
). Pseudoclasses are not very friendly in here when it comes to customization. I was almost thinking of creating a separate component for underline (kind of analogy to Fade
/ Grow
), but again, not a fan of creating additional DOM elements / components. CSS variables seems like the most reasonable option.
@optimista Did these demos help? https://material-ui.com/components/text-fields/#customized-inputs
Most helpful comment
@Co0sh What about?
https://codesandbox.io/s/q902qwo7q4