Add Angular Material to a project

ng add @angular/material
  • Select the theme indigo pink
  • Say yes to HammerJS
  • Say yes to browser animation of Angular Material

To test if the Angular material is added properly we add a angular button component and test it.

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatButtonModule} from '@angular/material';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MatButtonModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.html

<button mat-raised-button>Hello World</button>

Leave a Comment