-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextField/Select contrast color #21861
Comments
I don't think the |
@fbarbare Ok thanks, in this case, overrides sounds more appropriate |
@oliviertassinari |
Are you suggesting to have two different props? |
@oliviertassinari |
I'm against this proposal, if you need the dark theme, use the dark theme. What about something like this? TextFieldProps = {
color?: 'text.primary' | 'inherit'; // default text.primary
accentColor?: 'primary' | 'secondary'; // default primary
} |
That could work, though I would not call them TextFieldProps = {
textColor?: 'default' | 'inherit'; // default: default
color?: 'primary' | 'secondary'; // default: primary
} How would you get the inherited color? would it be possible to just apply |
@fbarbare Yeah, I was thinking of using |
I am not sure I understand what you mean about If a breaking change is not a big problem, I guess |
@fbarbare It's not very important, you were already on the right track :)
I don't know if it's that's better, I think that as long it's intuitive, we will be good. |
I quite like The only problem I have with
|
@oliviertassinari |
How often do we need the color inherit behavior vs how would we need to restore the color to text.primary because the color was changed by the container? Not sure 🤔 |
Yeah, I guess this would come back as an issue at some point... I could start drafting a PR if you want to tell me more about this |
@oliviertassinari Do you have any advice on how to tackle that? |
@oliviertassinari Any ideas? 🙂 |
@fbarbare I assume you are referring to: https://material.io/design/color/dark-theme.html#ui-application https://material.io/design/color/text-legibility.html#text-backgrounds We cover it in #21093. We could extract the alpha value from the color to apply it as an opacity. |
TinyColor (used by the VSCode plugin Peacock) has a function to help find the best contrast out of a list of possibles, if you guys are looking for something like that? |
@tomByrer We already have color helpers in colorManipulator.js. |
Any update on this? Using a dark theme doesn't make sense, for instance when you are putting light text on a dark hero image, but the page is still using a light theme. |
This issue can be closed by using CSS theme variables feature in v6 https://mui.com/material-ui/customization/css-theme-variables/configuration/#forcing-a-specific-color-scheme. |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @fbarbare How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Summary 💡
For Button and IconButton we have the possibility to set the
color
to things like"inherit"
which allows us to add readable buttons (like a drawer-menu button) on top of the AppBar:However, if we want to add a TextField or a Select, we cannot get its "default state" color to be changed accordingly to the background:
Examples 🌈
I suspect it wouldn't be easy to just use
inherit
here as different opacity applies to different elements (label/text/borders/disabled/...). So I was thinking that we could have another prop on the component likecontrastFrom= "primary" | "secondary"
or maybetheme= "light" | "dark"
and the input could then adapt its color to the used background color:Motivation 🔦
Some of the pages (not all of them) use the primary color as the main background color and I would like to add a Select in the footer so the user can change the language of the website.
I am able to achieve this by using the classes prop and overwriting the color of elements, but it's not ideal.
P.S. If we can agree on a way to do this, I could try to submit a PR
The text was updated successfully, but these errors were encountered: