You should implement changing the.scss style as below:
@import '~@angular/material/theming';
// Plus imports for other components in your app.
// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// Be sure that you only ever include this mixin once!
@include mat-core();
// Define the palettes for your theme using the Material Design palettes available in palette.scss
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
// hue. Available color palettes: https://material.io/design/color/
$candy-app-primary: mat-palette($mat-indigo);
$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);
// The warn palette is optional (defaults to red).
$candy-app-warn: mat-palette($mat-red);
// Create the theme object. A theme consists of configurations for individual
// theming systems such as `color` or `typography`.
$candy-app-theme: mat-light-theme((
color: (
primary: $candy-app-primary,
accent: $candy-app-accent,
warn: $candy-app-warn,
)
));
// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include angular-material-theme($candy-app-theme);
Source: Theming your Angular Material app
If you prefer a Dark theme, you should change the corresponding line to the code below:
// Create the theme object. A theme consists of configurations for individual
// theming systems such as `color` or `typography`.
$candy-app-theme: mat-dark-theme((
color: (
primary: $candy-app-primary,
accent: $candy-app-accent,
warn: $candy-app-warn,
)
));
The colors available are: $mat-red, $mat-pink, $mat-purple, $mat-deep-purple, $mat-indigo, $mat-blue, $mat-light-blue, $mat-cyan, $mat-teal, $mat-green, $mat-light-green, $mat-lime, $mat-yellow, $mat-amber, $mat-orange, $mat-deep-orange, $mat-brown, $mat-grey, $mat-blue-grey
.
But let’s say you want a color that is not in the above color list, in this case refer to the site Material Design Palette Generator, a name to your palette, adjust to the desired color, and review the contrast colors to look good, and click on the clipboard to see the code, choose Angular JS 2 (Material 2)
and there, copy and paste in style.scss and use in the construction of the theme.
As you created your project using a standard theme, you may need to change the angular.json
to point to style.scss
, would be at the point below:
projects/[SEU_APP]/architect/build/options/styles
View documentation here
One last tip, take a look at the Schematics project I’m developing:
angular-mat-Baum
I hope you like!
Hugs,
Bernardo Baumblatt
Do you want to create your own theme or use another pre-existing one? Like Indigo-pink, pink-bluegrey, Purple-green.css.
– Alex Parloti
I want to use a theme with different color of the predefined themes
– RRV