i am using angular material and a bit lost at theming. I am using the prebuilt indigo-pink theme which is included in my styles.scss as below
#import "~#angular/material/prebuilt-themes/indigo-pink.css";
Based on the doc i created a new file called theme.scss and included it in the angular.json after styles.scss. The theme.scss looks like below
#import '~#angular/material/theming';
#include mat-core();
$sg-app-primary: mat-palette($mat-indigo);
$sg-app-accent: mat-palette($mat-pink, A200, A100, A400);
$sg-app-theme: mat-light-theme($sg-app-primary, $sg-app-accent);
#include angular-material-theme($sg-app-theme);
My Requirement
I just need to change default font color to white rather black everywhere. I dont need to change anything else at all. I have copied the primary and accent pallete just from example. so feeling even they are not required to be changed.
I believe this post answers your question: https://stackoverflow.com/a/46157803/10730815. Basically, you need to build a custom foreground map and merge it into your theme. Combining your code snippet and the ones in the post above gives something like this for your styles.scss:
#import '~#angular/material/theming';
#include mat-core();
$sg-app-primary: mat-palette($mat-indigo);
$sg-app-accent: mat-palette($mat-pink, A200, A100, A400);
$sg-app-theme: mat-light-theme($sg-app-primary, $sg-app-accent);
#function my-mat-light-theme-foreground($color) {
#return (
base: $color,
divider: $white-12-opacity,
dividers: $white-12-opacity,
disabled: rgba($color, 0.38),
disabled-button: rgba($color, 0.38),
disabled-text: rgba($color, 0.38),
hint-text: rgba($color, 0.38),
secondary-text: rgba($color, 0.54),
icon: rgba($color, 0.54),
icons: rgba($color, 0.54),
text: rgba($color, 0.87),
slider-off: rgba($color, 0.26),
slider-off-active: rgba($color, 0.38),
slider-min: rgba($color, 0.38)
);
};
$white-foreground: my-mat-light-theme-foreground(white);
$my-app-theme-custom: map-merge($sg-app-theme, (foreground: $white-foreground));
#include angular-material-theme($my-app-theme-custom);
/* For the non-Angular Material items */
body {
color: white;
}
There are utility functions where you can pass in only a few of the necessary palettes such as primary, accent and warn and it will include background and foreground colors for you.
These functions can also be found in the scss provided by angular material file and if imported can be used when creating you theme configurations.
Here they are for reference so you can see how they automatically include the foregrounds and backgrounds for light and dark themes. Such awesome work by them.
#function _mat-create-light-color-config($primary, $accent, $warn: null) {
#return (
primary: $primary,
accent: $accent,
warn: if($warn != null, $warn, mat-palette($mat-red)),
is-dark: false,
foreground: $mat-light-theme-foreground,
background: $mat-light-theme-background,
);
}
#function _mat-create-dark-color-config($primary, $accent, $warn: null) {
#return (
primary: $primary,
accent: $accent,
warn: if($warn != null, $warn, mat-palette($mat-red)),
is-dark: true,
foreground: $mat-dark-theme-foreground,
background: $mat-dark-theme-background,
);
}
Related
In using this document. In attempting to change the text color in a mat-button I added a theme.scss to
the css project. Here is the theme.scss code:
#import '~#angular/material/theming';
#include mat-core();
$candy-app-primary: mat-palette($mat-indigo, 700, 300, 900);
$candy-app-accent: mat-palette($mat-light-blue, A400);
$candy-app-warn: mat-palette($mat-deep-orange, A200);
$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent,
$candy-app-warn);
#include angular-material-theme($candy-app-theme);
This is the html file:
<button mat-raised-button color="accent" routerLink="/">Home</button>
The accent color shows the expected accent, mat-light-blue, color. The text inside the button is still gray. The A400 is not displaying white as expected.
It is showing the same as expected. (mat-light-blue, A400) will have black as foreground color. I will suggest you to use range between 700 to 900 for getting white as foreground.
You can refer to below link for the reference for material design color pallate.
https://material.io/design/color/the-color-system.html#tools-for-picking-colors
And if you want to use the same color(A400) with white foreground, you can to do that with your own styling.
.mat-raised-button{
color: white !important;
}
You can apply light-theme custom settings for background and foreground(text colors). Insert this before applying your custom theme and use your color values instead of values in my example:
$mat-light-theme-background: (
background: $your_background,
status-bar: $light-bg-darker-20,
app-bar: $light-bg-darker-5,
hover: $dark-bg-alpha-4,
card: $light-bg-lighter-5,
dialog: $light-bg-lighter-5,
tooltip: $dark-bg-tooltip,
disabled-button: $dark-bg-alpha-12,
raised-button: #e5e5e5,
focused-button: $dark-focused,
selected-button: $light-bg-darker-20,
selected-disabled-button: $light-bg-darker-30,
disabled-button-toggle: $light-bg-darker-10,
unselected-chip: $light-bg-darker-10,
disabled-list-option: $light-bg-darker-10,
);
$mat-light-theme-foreground: (
base: $cdm-grey,
divider: $dark-dividers,
dividers: $dark-dividers,
disabled: $dark-disabled-text,
disabled-button: rgba($dark-text, 0.26),
disabled-text: $dark-disabled-text,
elevation: black,
secondary-text: $dark-accent-text,
hint-text: $dark-disabled-text,
accent-text: $dark-accent-text,
icon: $dark-accent-text,
icons: $dark-accent-text,
text: $dark-primary-text,
slider-min: $dark-primary-text,
slider-off: rgba($dark-text, 0.26),
slider-off-active: $dark-disabled-text,
);
I am using bootstrap 4 with SCSS and have troubles to find the variable which is responsible for the background of an "btn-primary" element which is active.
Of course I could just override the css file like that after the compiling process.
.btn-primary:not(:disabled):not(.disabled):active{
background-color:red;
}
But this is a bit hacky. I would like to undestand how bootstrap is generating this particular color? I am pretty sure I am missing something.
Please see this jsfiddle and click on the test button to see what I mean.
Solved: The color is stored within $primary (Thank you ReSedano)
Just do a
$primary: #ff00ff;
before you load bootstrap.
Here you can understand How to override boostrap4 using scss: How to extend/modify (customize) Bootstrap 4 with SASS.
In your case you have to override the map $theme-colors:
$theme-colors: (
"primary": #ff0000 // <= put here your color
);
To understand "how bootstrap is generating this particular color?" in _buttons.scss file you can find the function:
#each $color, $value in $theme-colors {
.btn-#{$color} {
#include button-variant($value, $value);
}
}
So to change colors, Bootstrap loop the map call $theme-colors that you find in _variable.scss file.
$theme-colors: () !default;
$theme-colors: map-merge(
(
"primary": $primary,
"secondary": $secondary,
"success": $success,
"info": $info,
"warning": $warning,
"danger": $danger,
"light": $light,
"dark": $dark
),
$theme-colors
);
this is a simple error . bootstrasp.css after style.css if yes can you move bootstrap.css before style.css
like
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="assets/bootstrap/dist/css/bootstrap.min.css">
<!-- custom CSS -->
<link rel="stylesheet" href="css/style.css">
use css in style.css
.btn-primary:not(:disabled):not(.disabled) {
background: red;
}
Theme colors is defined in _variables.scss
Buttons is generated in _buttons.scss and uses button-variant() mixin
// _variables.scss
$theme-colors: map-merge(
(
"primary": $primary,
"secondary": $secondary,
"success": $success,
"info": $info,
"warning": $warning,
"danger": $danger,
"light": $light,
"dark": $dark
),
$theme-colors
);
// _buttons.scss
#each $color, $value in $theme-colors {
.btn-#{$color} {
#include button-variant($value, $value);
}
}
Looking at the Angular Material documentation, they recommend using a -theme file per component to manage applying any theme-related styles to a specific class.
From my perspective, some downsides to this approach are:
quite verbose
splits up the style into two different locations
all your frontend devs need to understand how Angular Material colours work
makes it harder to change values (e.g. we might've been using mat-color($primary, 200) for border colours and now want to change it to mat-color($primary, 300). This will have been repeated all throughout the codebase.
Given a consistent design language, there will only be a subset of colors that will be used (e.g. 4 colors from the primary palette, 3 from the accent palette, a few different foreground / background colors, etc).
Given the above, doesn't it make more sense to have a _colors.scss that defines the exact colors using the theme rather than hoping developers extract the correct value from the theme each time?
e.g. maybe something like:
$clr-primary-default: mat-color($primary);
$clr-primary-contrast: mat-color($primary, default-contrast);
$clr-primary-light: mat-color($primary, lighter);
$clr-primary-dark: mat-color($primary, darker);
$clr-accent-default: mat-color($accent);
$clr-accent-light: mat-color($accent, lighter);
$clr-accent-dark: mat-color($accent, darker);
$clr-default-text: mat-color($foreground);
$clr-secondary-text: mat-color($foreground, secondary-text);
//etc
Then rather than creating a separate -theme file for each component that requires specific colors, I can simply import the colors.scss file and use the variables directly in the *.component.scss file.
Just wanting to validate that the above is sound and that I'm not missing anything obvious that's going to cause pain down the track?
The other tricky part is how to actually define these in a separate colors file efficiently given the file will need access to the theme data.
Why use #mixin?
Just wanting to validate that the above is sound and that I'm not missing anything obvious that's going to cause pain down the track?
The only thing, I can think of, is that you would miss the opportunity to use multiple themes in one application. With the approach from the Angular Material documentation, you would have a #mixin for each component, that you can #include multiple times with different $theme variables.
Example from https://medium.com/#tomastrajan/the-complete-guide-to-angular-material-themes-4d165a9d24d1:
.default-theme {
#include angular-material-theme($theme);
#include custom-component-theme($theme);
}
.light-theme {
#include angular-material-theme($light-theme);
#include custom-component-theme($light-theme);
}
This wouldn't work, if you import colors as scss-variables into your components and use it there.
Separate file for colors
The other tricky part is how to actually define these in a separate colors file efficiently given the file will need access to the theme data.
This is actually pretty straight forward: I have a separate file src/styles/_variables.scss that contains my custom colors as scss-variables and also the $theme variable, that I am using later in src/theme.scss.
#import '~#angular/material/theming';
// Theme configuration
$primary: mat-palette($mat-blue, 800, 500, 900);
$accent: mat-palette($mat-blue, A200, A100, A400);
$warn: mat-palette($mat-red);
$theme: mat-light-theme($primary, $accent, $warn);
// Custom colors
$custom-colors: (
custom-color-a: mat-color($mat-green, 700),
custom-color-b: mat-color($mat-red, 400),
);
$theme: map-merge($theme, (custom-colors: $custom-colors));
To import my _variables.scss inside a component, I have to add stylePreprocessorOptions to the angular.json file:
"styles": [
"src/styles.scss",
"src/theme.scss"
],
"stylePreprocessorOptions": {
"includePaths": [
"src/styles"
]
},
Now I can import my variables in all scss-files of my components:
#import 'variables';
.custom-class-a {
background-color: map-get($custom-colors, custom-color-a);
color: map-get($custom-colors, custom-color-b);
}
Why do I use a sass-map and map-merge?
As you noticed, I collect my custom colors in the sass-map $custom-colors and merge them into my $theme variable. This way I could either use my custom colors by directly importing it into my components style sheet (as described above) or I could use them inside my components #mixin the way it is described in the Angular Material documentation.
#import '~#angular/material/theming';
#mixin custom-component-theme($theme) {
$custom-colors: map-get($theme, custom-colors);
.custom-class-a {
background-color: map-get($custom-colors, custom-color-a);
color: map-get($custom-colors, custom-color-b);
}
}
Maybe this combination is a way that your frontend devs could work with?
I have defined primary,accent and warn colors as css custom variables in the styles.css file like so:
#import "~#angular/material/theming";
#include mat-core();
$my-primary: mat-palette($mat-blue-grey);
$my-accent: mat-palette($mat-amber, A200, A100, A400);
$my-warn: mat-palette($mat-deep-orange);
$my-2-primary: mat-palette($mat-pink, 400, 200, 600);
$my-2-accent: mat-palette($mat-blue, A200, A100, A400);
$my-2-warn: mat-palette($mat-deep-orange, 500, 300, 700);
.dark-theme {
$my-theme-dark: mat-dark-theme($my-primary, $my-accent, $my-warn);
#include angular-material-theme($my-theme-dark);
$primary: mat-color($my-primary);
$accent: mat-color($my-accent);
$warn: mat-color($my-warn);
$fg_palette:map-get($my-theme-dark, foreground);
$bg_palette:map-get($my-theme-dark, background);
$fg:map-get($fg_palette, text);
$bg:map-get($bg_palette, background);
--primary: #{$primary};
--accent: #{$accent};
--warn: #{$warn};
--fg: #{$fg};
--bg: #{$bg};
}
.dark-theme-2 {
$my-2-theme-dark: mat-dark-theme($my-2-primary, $my-2-accent, $my-2-warn);
#include angular-material-theme($my-2-theme-dark);
$primary: mat-color($my-2-primary);
$accent: mat-color($my-2-accent);
$warn: mat-color($my-2-warn);
$fg_palette:map-get($my-2-theme-dark, foreground);
$bg_palette:map-get($my-2-theme-dark, background);
$fg:map-get($fg_palette, text);
$bg:map-get($bg_palette, background);
--primary: #{$primary};
--accent: #{$accent};
--warn: #{$warn};
--fg: #{$fg};
--bg: #{$bg};
}
And used these variables in any of my components like so:( in my-custom-component.scss)
.some-class {
color: var(--primary)
}
.another-class {
background-color: var(--bg)
}
.yet-another-class {
border-color: var(--accent)
}
By doing like this, i can change any value related to color in any component, because these variables are global (defined in styles.css)
As i change theme, these colors also change according to new theme's color
I am working on a project where I used the Material 2 Themes and I used this approach where I use the class name and add colors class globally.
This is what I did :
FileName: mytheme-sidemenu.scss:
// Import all the tools needed to customize the theme and extract parts of it
#import "~#angular/material/theming";
// Define a mixin that accepts a theme and outputs the color styles for the component.
#mixin mytheme-sidemenu($theme) {
// Extract whichever individual palettes you need from the theme.
$primary: map-get($theme, primary);
$accent: map-get(
$theme,
accent
); // Use mat-color to extract individual colors from a palette as necessary.
.col-primary {
color: mat-color($primary, 500) !important;
}
.col-accent {
color: mat-color($accent, 300) !important;
}
}
Here is my main theme file:
mytheme-theme.scss:
#import '~#angular/material/theming';
#import './variables/helper.scss';
#import './variables/spacemanager.scss';
#import './mytheme-sidemenu.scss';
// Primary theme
#include mat-core();
$mytheme-app-primary: mat-palette($mat-light-blue, 700, 600);
$mytheme-app-accent: mat-palette($mat-pink, A200, 900, A100);
$mytheme-app-warn: mat-palette($mat-deep-orange);
$mytheme-app-theme: mat-light-theme($mytheme-app-primary, $mytheme-app-accent, $mytheme-app-warn);
#include angular-material-theme($mytheme-app-theme);
// Secondary Theme
.mytheme-alt-theme {
$mytheme-alt-primary: mat-palette($mat-blue-grey, 500);
$mytheme-alt-accent: mat-palette($mat-pink, 500);
$mytheme-alt-warn: mat-palette($mat-deep-orange);
$mytheme-alt-theme: mat-light-theme($mytheme-alt-primary, $mytheme-alt-accent, $mytheme-alt-warn);
#include angular-material-theme($mytheme-alt-theme);
}
// Using the $theme variable from the pre-built theme you can call the theming function
#include mytheme-sidemenu($mytheme-app-theme);
and in app.module.ts update this :
export class AppModule {
constructor(
#Inject(OverlayContainer) private overlayContainer: OverlayContainer
) {
this.overlayContainer
.getContainerElement()
.classList.add("mytheme-alt-theme"); // this for double theme add to the root css class
}
}
I am using angular 5 material and i created a theme.scss as below
theme.scss
#import '~#angular/material/theming';
#include mat-core();
$custom-primary: mat-palette($mat-deep-purple,600);
$custom-accent: mat-palette($mat-lime, 100);
$custom-warn: mat-palette($mat-red);
$custom-theme: mat-light-theme($custom-primary, $custom-accent, $custom-warn);
#include angular-material-theme($custom-theme);
// ALTERNATIVE THEME
$alt-primary: mat-palette($mat-yellow);
$alt-accent: mat-palette($mat-grey, 200);
$alt-theme: mat-dark-theme($alt-primary, $alt-accent);
.alternative {
#include angular-material-theme($alt-theme);
}
I have my default styles.scss as below
style.scss
#import "~#angular/material/prebuilt-themes/indigo-pink.css";
.fa-icon-nav {
color: #507889;
font-size: x-large;
}
The color is currently hardcoded in the fa-icon-nav. I want it to use primary color from the currently selected theme. Please advise how this would work if possible? Happy to hear if this is totally the wrong way to do it and how it should be done.
EDIT:
ADDED ONLINE DEMO
I am working on a project where I used the Material 2 Themes and I used this approach where I use the class name and add colors class globally.
This is what I did :
FileName: mytheme-sidemenu.scss:
// Import all the tools needed to customize the theme and extract parts of it
#import "~#angular/material/theming";
// Define a mixin that accepts a theme and outputs the color styles for the component.
#mixin mytheme-sidemenu($theme) {
// Extract whichever individual palettes you need from the theme.
$primary: map-get($theme, primary);
$accent: map-get(
$theme,
accent
); // Use mat-color to extract individual colors from a palette as necessary.
.col-primary {
color: mat-color($primary, 500) !important;
}
.col-accent {
color: mat-color($accent, 300) !important;
}
}
Here is my main theme file: mytheme-theme.scss:
#import '~#angular/material/theming';
#import './variables/helper.scss';
#import './variables/spacemanager.scss';
#import './mytheme-sidemenu.scss';
// Primary theme
#include mat-core();
$mytheme-app-primary: mat-palette($mat-light-blue, 700, 600);
$mytheme-app-accent: mat-palette($mat-pink, A200, 900, A100);
$mytheme-app-warn: mat-palette($mat-deep-orange);
$mytheme-app-theme: mat-light-theme($mytheme-app-primary, $mytheme-app-accent, $mytheme-app-warn);
#include angular-material-theme($mytheme-app-theme);
// Secondary Theme
.mytheme-alt-theme {
$mytheme-alt-primary: mat-palette($mat-blue-grey, 500);
$mytheme-alt-accent: mat-palette($mat-pink, 500);
$mytheme-alt-warn: mat-palette($mat-deep-orange);
$mytheme-alt-theme: mat-light-theme($mytheme-alt-primary, $mytheme-alt-accent, $mytheme-alt-warn);
#include angular-material-theme($mytheme-alt-theme);
}
// Using the $theme variable from the pre-built theme you can call the theming function
#include mytheme-sidemenu($mytheme-app-theme);
and in app.module.ts update this :
export class AppModule {
constructor(
#Inject(OverlayContainer) private overlayContainer: OverlayContainer
) {
this.overlayContainer
.getContainerElement()
.classList.add("mytheme-alt-theme"); // this for double theme add to the root css class
}
}
This is already asked and I just copy paste my answer from here
EDIT :
As per your need, you can achieve this:
I have my default styles.scss as below style.scss that you need to change to _theme-color.scss
.fa-icon-nav {
color: mat-color($primary, 500) !important; // 500, 600 , 700 check material color pallet for more info
// You can use this too
// color: mat-color($alt-primary, 500) !important;
font-size: x-large;
}
or you can use this material color library from here
In the official theming documentation of Angular Material2 it states clearly the following:
In Angular Material, a theme is created by composing multiple palettes. In particular, a theme consists of:
A primary palette: colors most widely used across all screens and components.
An accent palette: colors used for the floating action button and interactive elements.
A warn palette: colors used to convey error state.
A foreground palette: colors for text and icons.
A background palette: colors used for element backgrounds.
But in every example they modify only the first three:
#import '~#angular/material/theming';
#include mat-core();
$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);
$candy-app-warn: mat-palette($mat-red);
$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent, $candy-app-warn);
#include angular-material-theme($candy-app-theme);
So my question is: How can I change the foreground palette in order to change the color of the text for the primary or the secondary palette?
There are some websites (materialpalette.com, material.io) which show the color palette for easy visualization but still they don't say how to include or modify that palette in Angular Material2.
You can change the default theme color by creating your own foreground map and merge it into the created theme before initializing it. Here is how:
Build the theme object as usual.
#import '#angular/material/theming.scss';
#include mat-core();
// Choose colors
$my-app-primary: mat-palette($mat-blue-grey);
$my-app-accent: mat-palette($mat-light-green);
$my-app-warn: mat-palette($mat-red);
// Build theme object (its practically a map object)
$my-app-theme: mat-light-theme($my-app-primary, $my-app-accent, $my-app-warn);
Build your custom foreground using a custom function returning foreground map as defined in #angular/material/_theming.scss -> $mat-light-theme-foreground function.
You can play with the map and define only the fields you want and leave the others as default.
#function my-mat-light-theme-foreground($color) {
#return (
base: $color,
divider: $black-12-opacity,
dividers: $black-12-opacity,
disabled: rgba($color, 0.38),
disabled-button: rgba($color, 0.38),
disabled-text: rgba($color, 0.38),
hint-text: rgba($color, 0.38),
secondary-text: rgba($color, 0.54),
icon: rgba($color, 0.54),
icons: rgba($color, 0.54),
text: rgba($color, 0.87),
slider-min: rgba($color, 0.87),
slider-off: rgba($color, 0.26),
slider-off-active: rgba($color, 0.38),
);
};
// You can put any color here. I've chosen mat-color($my-app-primary, 700)
$my-foreground: my-mat-light-theme-foreground(mat-color($my-app-primary, 700));
Merge the previously created theme with just the foreground map and initialize your custom theme.
Note: Since all maps in SCSS are immutable the map-merge() returns new map instance and DOES NOT modify the map in place - thus we have another variable $my-app-theme-custom to hold the result theme.
$my-app-theme-custom: map-merge($my-app-theme, (foreground: $my-foreground));
// Include your custom theme.
#include angular-material-theme($my-app-theme-custom);
Note: I'm using Angular Material v2.0.0-beta.8
EDIT Oct 2020: - I've added the property slider-min to the map since couple of folks in the comments reported it was added in the foreground map in later builds.
The guide is available at the documentation website located here.
First, you define the palettes for your theme, such as $primary, $accent, $warn (in the guide they have $candy-app- prefix) and then create a $theme object:
// Create the theme object (a Sass map containing all of the palettes).
$theme: mat-light-theme($primary, $accent, $warn);
Once we have a theme that contains all the palettes, we can get a foreground palette from it:
$foreground: map-get($theme, foreground);
From $foreground palette we can get any values based on a key, such as
secondary-text: rgba(black, 0.54),
or
text: rgba(black, 0.87)
Here's the code to retrieve the secondary-text property:
color: mat-color($foreground, secondary-text);
I switched to 2.0.0-beta.3 from 2.0.0-beta.2 and the folders structure looks different, you are right.
It is now \node_modules\#angular\material\_theming.scss, _palette.scssfile is gone. You can do global search for it though: '$mat-dark-theme-background: ('
_theming.scss has all the colors, maps and all the functions, like mat-color
To change foreground text color, first create your theme as per usual, then override theme.color.foreground.text:
// define theme as you do currently, e.g.
$theme: mat.define-light-theme(...)
/ grab color.foreground map from theme
$color: map-get($map: $theme, $key: color);
$foreground: map-get($map: $color, $key: foreground);
// override text of foreground map
$my-text-color: #3B4956;
$themed-foreground: map-merge($foreground, (text: $my-text-color));
// override foreground of $color map
$themed-color: map-merge($color, (foreground: $themed-foreground));
// override color of theme map
$theme: map-merge($theme, (color: $themed-color));
Proceed to generate css from $theme as per usual, ie #include mat.all-component-themes($theme) - make sure this is only done once. One way to achieve this:
_theme.scss
// contains above theme - ok to include many places
theming.scss
// generates css - only include once!
#import './theme';
...
#include mat.all-component-themes($theme)
I am surprised it isn't possible to do this in an easier way - expecting that will eventually change. Good luck.
Update for Angular Material >14
I have been using nyxz's answer above but since Angular 14 the only way I have been able to successfully override the theme foreground is with this:
$my-app-theme: mat.define-light-theme(
(
color: (
primary: $my-app-primary,
accent: $my-app-accent,
warn: $my-app-warn
),
typography: $custom-typography
)
);
$my-app-colors: map.get($my-app-theme, color);
$my-app-olors: map.merge(
$my-app-colors,
(
foreground: $my-foreground
)
);
$my-app-theme: map.merge(
$my-app-theme,
(
color: $my-app-colors
)
);
Here's the code:
// Foreground palette for light themes.
$mat-light-theme-foreground: (
base: black,
divider: rgba(black, 0.12),
dividers: rgba(black, 0.12),
disabled: rgba(black, 0.38),
disabled-button: rgba(black, 0.38),
disabled-text: rgba(black, 0.38),
hint-text: rgba(black, 0.38),
secondary-text: rgba(black, 0.54),
icon: rgba(black, 0.54),
icons: rgba(black, 0.54),
text: rgba(black, 0.87)
);
You can find the map at: \node_modules\#angular\material\core\theming\
_palette.scss
Example retrieving 'secondary-text':
$foreground: map-get($theme, foreground);
.foreground-color {
color: mat-color($foreground, secondary-text);
}