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.

[mdc-card] Text color is not being set based on current theme color palette

See original GitHub issue

Bug report

Text color is not being set based on current theme color palette

Steps to reproduce

  1. Create a custom theme with different values for surface and on-surface colors. In my case i’m creating a dark theme where surface is black and on-surface is white.
  2. Compile your scss styles.
  3. Check card component styles.

Actual behavior

Text color is set to black instead of white.

Expected behavior

Text color should be white since that is the value that $on-surface has.

Additional context

By looking at the base mdc-card styles i see that background-color is being set to surface but color is inherited:

.mdc-card {
  border-radius: 4px;
  background-color: #212121;
  /* @alternate */
  background-color: var(--mdc-theme-surface, #212121);
  /* @alternate */
  position: relative;
  /* @alternate */
  box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

Possible solution

@use "@material/theme";

.mdc-card {
 color: theme.$on-surface;
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
asyncLizcommented, Mar 13, 2020

This makes sense to us. Adding it to our backlog to add on-surface foreground color to cards. We’ll do some investigating to make sure this doesn’t break anything.

1reaction
asyncLizcommented, Mar 10, 2020

I’ll bring this up with the team this week!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Theming guide - Material Design
Sets the background color to the theme primary color. mdc-theme--on-primary, Sets the text color to the color configured for text on the primary...
Read more >
Text color not working in Material-UI Theme - Stack Overflow
In order to have white text for both colors, you want: const colortheme = createMuiTheme({ palette: { primary: { main: "#e91e63", ...
Read more >
Create or delete a custom theme color - Microsoft Support
In the Name box, type a name for your custom theme color, and then click Save. The theme color is applied to the...
Read more >
Video: Customize colors and save the theme - Microsoft Support
How do you change only one color of the current color scheme, rather than the entire color scheme, and change things like the...
Read more >
Angular Material Theming System - Complete Guide
In Angular Material, a theme is a collection of color and typography options. Each theme includes three palettes that determine component colors: primary, ......
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