2016-11-26 84 views
1

我是新角2材料设计我看到的东西是3类的主要口音和警告,给元素各自的颜色,这些只是我们可以使用角材2来制作应用程序?还有其他班吗?所以我们可以修改和使用它的目的,或者我们必须通过制作类和附加到元素从头开始设计我们的应用程序,什么是最好的方式使用角2材料设计

另外我想使用主题,但我dnt知道如何在角度中使用它2项目,IM以下官方文件 this

我包含在style.css的这条线,但什么都没有发生

@import '[email protected]/material/core/theming/prebuilt/deeppurple-amber.css' 

是什么主题的BTW

回答

1

如果您正在使用角CLI概念,我建议你这样做。

在您的应用程序文件夹中创建一个'custom-theme.scss'。

@import '[email protected]/material/core/theming/all-theme'; 
// Plus imports for other components in your app. 

// Include the base styles for Angular Material core. We include this here so that you only 
// have to load a single css file for Angular Material in your app. 
@include md-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. 
$primary: md-palette($md-indigo); 
$accent: md-palette($md-pink, A200, A100, A400); 

// The warn palette is optional (defaults to red). 
$warn: md-palette($md-red); 

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

在您的角cli.json自定义样式添加到样式:

app/custom-theme.scss 
+0

这是风格的应用程序使用angular2材料设计的唯一途径,创建自定义主题?或者我们可以采用什么样的方式,上课? – blackHawk

+0

这是正确的做法,你也可以重写他们的风格,但不建议。 – Ploppy