Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Angular Material 2主题设置为深色主题_Angular_Themes_Angular Material - Fatal编程技术网

将Angular Material 2主题设置为深色主题

将Angular Material 2主题设置为深色主题,angular,themes,angular-material,Angular,Themes,Angular Material,我最近创建了一个Angular Material 2应用程序。现在我想知道如何将主题更改为深色或深色主题?在style.CSS文件中添加以下CSS: @import '~@angular/material/core/theming/all-theme'; // NOTE: Theming is currently experimental and not yet publically released! @include md-core(); $primary: md-palette($m

我最近创建了一个Angular Material 2应用程序。现在我想知道如何将主题更改为深色或
深色主题

在style.CSS文件中添加以下CSS:

@import '~@angular/material/core/theming/all-theme';

// NOTE: Theming is currently experimental and not yet publically released!

@include md-core();

$primary: md-palette($md-deep-purple);
$accent:  md-palette($md-amber, A200, A100, A400);

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

@include angular-material-theme($theme);

$dark-primary: md-palette($md-pink, 700, 500, 900);
$dark-accent:  md-palette($md-blue-grey, A200, A100, A400);
$dark-warn:    md-palette($md-deep-orange);

$dark-theme: md-dark-theme($dark-primary, $dark-accent, $dark-warn);

@include angular-material-theme($dark-theme);

注意:从当前版本:2.0.0-beta.3开始,将以下内容添加到您的全局
sass
文件中

@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.
$dark-primary: mat-palette($mat-blue-grey);
$dark-accent:  mat-palette($mat-amber, A200, A100, A400);

// The warn palette is optional (defaults to red).
$dark-warn:    mat-palette($mat-deep-orange);

// Create the theme object (a Sass map containing all of the palettes).
$cdark-theme: mat-light-theme($dark-primary, $dark-accent, $dark-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($cdark-theme);

可能会有帮助,因为上面代码的语言是SCS而不是css。@mojtab23 css中不支持变量(至少广泛支持)。SCSS是覆盖CSS的唯一方法。是的,这是正确的答案。您需要使用SCS来构建自定义主题,或者您需要使用预构建的暗主题。在最新版本中,将md xxx更改为mat xxx!示例:md调色板现在是mat调色板。。。