components: bug(MatTable): Text-color are no longer taken from the predefined foreground palette
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
14
Description
After the angular material 15 update, the component text colors are no longer taken from the predefined foreground palette. In the past there was taken from the text and secondary-text variable.
Is there a new smart way to force the use of specific text-colors? Or is it not advisable to use your own font colors?
Reproduction
https://stackblitz.com/run?file=src%2Fapp%2Ftable-basic-example.ts
Expected Behavior
Its possible to use the foreground color palette to customize the text-color.
$theme-foreground-palette: (
base: color.$grey-700,
divider: color.$dividers,
dividers: color.$dividers,
disabled: color.$disabled-text,
disabled-button: color.$grey-400,
disabled-text: color.$disabled-text,
elevation: color.$grey-700,
hint-text: color.$disabled-text,
secondary-text: color.$secondary-text, // <-- was also used for mat-header-cells
icon: color.$primary-text,
icons: color.$primary-text,
text: color.$primary-text, // <-- was also used for mat-cells
slider-min: color.$grey-700,
slider-off: color.$grey-200,
slider-off-active: color.$grey-300,
);
Actual Behavior
Some parts from the foreground palette will affect in the theme for the app. But in lists, tables or options there is always used the color rgba(0, 0, 0, 0.87)
.
Environment
- Angular: 15.0.2
- CDK/Material: 15.0.1
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 41
- Comments: 30 (5 by maintainers)
Angular 16 is already live, and this is not fixed. Any news on this?
The tl;dr is that we’re mapping our theming system onto MDC’s and some thing fell through the cracks. We’re currently designing a new theming API that should map better.
Still a problem in version 17
I think a better approach would’ve been
And that for all
$on-
variablesThis should’ve been resolved by https://github.com/angular/components/pull/27192.
@elvince You can find more information here: https://material.angular.io/guide/mdc-migration#what-has-changed
Notify me if resolved.
Hello, will it be integrated in a roadmap ? I will keep using legacy components till this issue is solved.
Great to hear it’s being addressed. Is there a rough time estimate and is there a suggested work-around for the time being?
hi, I’m facing the same issue. any hint to setup properly the colors would be aprecitated. The docs are not relevant on this topics as it is not working anymore.
Thanks,
When I try to use the above custom palette
Then I expect the primary’s text font color for mat-radio-button be red.
Environment
Angular: 17.3.2 CDK/Material: 17.3.2
EDIT: Turns out this is a known bug and will be fixed soon. https://github.com/angular/components/issues/26056
Still a problem in “@angular/material”: “17.1.2”
Are you importing the legacy button like this?
That works for me, but you then get a bunch of deprecation warnings in your IDE.
Related:
@crisbeto You’ve done a fair bit of work in this area already. Are you able to comment on why the move to MDC broke user defined contrast colors?