Angular + Material | How to Install Angular Material in Angular Project

In this tutorial, we will go through quick steps to Install Angular Material in Angular project and also discuss how to add themes and different Material Components in an Angular project.

Angular Material is a UI framework based on Material concepts of designs. It is a mobile-first framework properly built for Angular. The material provides a number of easy to add and use flexible UI web components, which works mailing on different device screen sizes.

To start the Material installation, first, we will create a new Angular project using Ng CLI tool using Command prompt terminal.

Make sure you have NodeJS installed to use NPM which Node Package Manager used to install packages directly from the terminal.

Install Ng CLI

Angular/NG CLI tool makes Angular development very easy by providing easy commands to generate services, components, directive, etc.

Run following CMD command to install CLI tool

$ npm install -g @angular/cli

Create a new Angular Project

As now we have NG CLI tool install, we can easily create a new Angular project by running following command in CLI

$ ng new HeyAngularMaterial

After running above command it will ask if you want Routing in the project? and also about CSS style formats you want to opt for the project.

Install Angular Material

To install Angular Material in Angular project run following npm CLI command to install Material, CDK and Animation packages.

$ npm install --save @angular/material @angular/cdk @angular/animations

Enable Animation for Material Components

Animations like smooth scrolling effect, ripple effect on button click need to be enabled or disabled by importing following modules.

In the app.module.ts file make the following changes:

Enable Animations:

import {BrowserAnimationsModule} from '@angular/platform-browser/animations';

  imports: [BrowserAnimationsModule],

Disable Animations:

import {NoopAnimationsModule} from '@angular/platform-browser/animations';

  imports: [NoopAnimationsModule],

Add Material Theme

Components used in the project are styles using CSS available in the material CSS theme file, so just add the following theme file link in styles.css available at the project root.

@import "~@angular/material/prebuilt-themes/deeppurple-amber.css";
/* @import "~@angular/material/prebuilt-themes/indigo-pink.css"; */
/* @import "~@angular/material/prebuilt-themes/pink-bluegrey.css"; */
/* @import "~@angular/material/prebuilt-themes/purple-green.css"; */

you can use any one of these available themes.

That’s it … we are done with Angular material configuration.

How to use Material Components?

To use an Angular Material component like buttons, autocomplete, tabs, etc, first you need to add their modules in your project’s app.module.ts file. So that they will be available to every component under that module.

For example, if you want to use Material Buttons, import MatButtonModule then add in the imports array.

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

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { 
 } from '@angular/material';

  declarations: [
  imports: [

  entryComponents: [
  providers: [],
  bootstrap: [AppComponent]
export class AppModule { }


2 thoughts on “Angular + Material | How to Install Angular Material in Angular Project”

  1. Pingback: Angular 8 + Material | Adding Tabs Component in Angular using Material v8.x.x « Freaky Jolly

  2. Pingback: Angular 9|8|7 Material Inline MatCalender/ Datepicker Tutorial by Example « Freaky Jolly

Leave a Comment

Your email address will not be published. Required fields are marked *

istanbul escortHacklinkartvin escortGiresun escortEscortporno izleizmir escortsincan escortistanbul escortizmir escortGaziantep escortşişli escortkartal escortbodrum escortAntalya escortMarmaris escortpornoankara escortistanbul escortizmir escortizmir escort çilingironwin girişHacklink satın alçankaya escortAyvalık Escortkütahya escortgümüşhane escortAksaray escortaydın escortkayseri escortçankaya escortkızılay escortkeçiören escorthepabeteryaman escortKiralık Bahis Siteleribonus veren sitelerKiralık Bahis Siteleri
Diş eti ağrısıankara kocaeli nakliyatgüvenlik bariyerisakarya evden eve nakliyatgaziantep evden eve nakliyatnargilehttps://www.orneknakliyat.comseowordpress en iyi seo eklentileripuro satın alBeard Transplantizmir saç ekimiistanbul evden eve nakliyatimplantbebekeskişehir inşaat şirketleriantika eşya alanlarantika eşya alanlarGülüş Tasarımıantalya haberCar Accident Lawyerpgcdpmsagaziantep boşanma avukatıAntika alan yerlermaltepe antika eşya alanlar