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.

TextField/Select contrast color

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

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: image

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: image

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 like contrastFrom= "primary" | "secondary" or maybe theme= "light" | "dark" and the input could then adapt its color to the used background color: image

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:22 (20 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

TextField/Select contrast color #21861 - mui/material-ui - GitHub
I am able to achieve this by using the classes prop and overwriting the color of elements, but it's not ideal.
Read more >
Changing TextField color in a react/material ui - Stack Overflow
I want them to appear green on a black background, and I'm not able to change the default colors of all elements. Based...
Read more >
Contrast (Minimum) - Low Vision Accessibility Task Force
The selected tab's color of black (#000000) has a contrast of at least 3 to 1 with the color of the white (#FFFFFF)...
Read more >
Text elements must have sufficient color contrast against the ...
Checks all text elements to ensure that the contrast between the foreground text and the background colors meet the WCAG 2 AA contrast...
Read more >
color-contrast() - CSS: Cascading Style Sheets - MDN Web Docs
The color-contrast() functional notation takes a color value and compares it to a list of other color values, selecting the one with the ......
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