Angular Material 2 has an official Getting Started guide. Hence this guide focuses on integrating Angular Material 2 in the app architecture generated by Angular CLI.
yarn add @angular/material
yarn add @angular/animations
yarn add hammerjs
Open src/app/app.module.ts and add specific Angular Material modules and hammerjs. Here were are including just the MD Button.
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MdButtonModule } from '@angular/material';
import 'hammerjs';
@NgModule({
...
imports: [
MdButtonModule,
BrowserAnimationsModule
],
...
})Open src/style.[scss/less/css] and add the following import statement at the top.
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';Open src/index.html and add mat-app-background class to the body tag.
<body class="mat-app-background">If you are ready to get started with your custom theme, follow the official Theming your Angular Material app
Include the following link tag in src/index.html
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">Head over to Angular Material to see all the supported components.
For example, try adding the following button element inside one of your components.
<button md-raised-button color="primary">This is it!</button>It should render like the following!
