首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将Angular Material 2主题设置为暗主题

将Angular Material 2主题设置为暗主题
EN

Stack Overflow用户
提问于 2017-01-17 03:56:57
回答 2查看 16.5K关注 0票数 5

我最近通过这个guide创建了一个Angular Material 2应用程序。现在我想知道如何将主题更改为dark或dark-theme

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-17 16:09:37

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

代码语言:javascript
运行
复制
@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);

P.S. https://github.com/jelbourn/material2-app/blob/master/src/material2-app-theme.scss

票数 11
EN

Stack Overflow用户

发布于 2017-04-13 04:47:51

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

代码语言:javascript
运行
复制
@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);

More details

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41684093

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档