码迷,mamicode.com
首页 > 其他好文 > 详细

[Angular] Define a custom Material theme

时间:2020-02-05 09:28:05      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:define   htm   OLE   color   init   def   ras   bee   bsp   

// include all the scss
@import "~@angular/material/theming";

// Include non-theme styles for core.
@include mat-core();

$mat-custom-primary-theme: (
  50: #ffebee,
  100: #ffcdd2,
  200: #ef9a9a,
  300: #e57373,
  400: #ef5350,
  500: #e1234e,
  600: #e53935,
  700: #d32f2f,
  800: #c62828,
  900: #b71c1c,
  A100: #ff8a80,
  A200: #ff5252,
  A400: #ff1744,
  A700: #d50000,
  contrast: (
    50: $dark-primary-text,
    100: $dark-primary-text,
    200: $dark-primary-text,
    300: $dark-primary-text,
    400: $dark-primary-text,
    500: $light-primary-text,
    600: $light-primary-text,
    700: $light-primary-text,
    800: $light-primary-text,
    900: $light-primary-text,
    A100: $dark-primary-text,
    A200: $light-primary-text,
    A400: $light-primary-text,
    A700: $light-primary-text
  )
);

// Define a theme.
$primary: mat-palette($mat-custom-primary-theme);
$accent: mat-palette($mat-pink, A200, A100, A400);

$theme: mat-light-theme($primary, $accent);

// Include all theme styles for the components.
@include angular-material-theme($theme);

// Our dark theme
.dark-theme {
   $theme: mat-dark-theme($primary, $accent);
   @include angular-material-theme($theme);
}

 Add those in to styles.scss

 

In app.component.html, add ‘dark-theme‘ class by condition:

<main [ngClass]="{ ‘dark-theme‘: dark }">

</main>

 

ts file:

export class AppComponent implements OnInit {
  dark: boolean = false;

}

 

[Angular] Define a custom Material theme

标签:define   htm   OLE   color   init   def   ras   bee   bsp   

原文地址:https://www.cnblogs.com/Answer1215/p/12262378.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!