[mdc-card] Text color is not being set based on current theme color palette
See original GitHub issueBug report
Text color is not being set based on current theme color palette
Steps to reproduce
- Create a custom theme with different values for
surface
andon-surface
colors. In my case i’m creating a dark theme wheresurface
is black andon-surface
is white. - Compile your scss styles.
- 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:
- Created 4 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
I’ll bring this up with the team this week!