How to import Angular Material in project?

install angular material
@angular/material is not a module
angular material button
angular material for angular 7
angular material template
uninstall angular material
angular material themes
angular material example

I have installed Angular Material Design. Now I try to add this in app.module.ts file:

import { MaterialModule } from '@angular/material';

What I should decify in section: imports: []? that to load all material entities.

I tried: imports: ['MaterialModule'] but it is deprecated

How to import Angular Material in project?, another dependency to your project, you can use the NoopAnimationsModule . import {NoopAnimationsModule} from '@angular/platform-browser/animations'  How to Import Angular Material — Angular Best Practices. Mehdi Benmoha. Follow. A very common mistake is to put every single angular material module in the shared module, that works but you

If you want to import all Material modules, create your own module i.e. material.module.ts and do something like the following:

import { NgModule } from '@angular/core';
import * as MATERIAL_MODULES from '@angular/material';

export function mapMaterialModules() {
  return Object.keys(MATERIAL_MODULES).filter((k) => {
    let asset = MATERIAL_MODULES[k];
    return typeof asset == 'function'
  }).map((k) => MATERIAL_MODULES[k]);
const modules = mapMaterialModules();

    imports: modules,
    exports: modules
export class MaterialModule { }

What Is Angular Material and How to Use It?, UPDATE for Angular 9.0.1. Since this version there is no barrel file for massive exports in the root index.d.ts. The assets imports should be: 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.

Getting started with Angular Material, Step 2: Create a workspace for Angular Project. To create a new Step 5: Import the Angular Material component modules. Imports the  The steps to properly import Angular Material are: Adding Material directly to the app.module will quickly increase the size of the module, which makes it more difficult If you ever wanted to replace the UI components with a new framework like Kendo-UI, it will be harder to do as Material

Starting from Angular version 9:

Breaking changes:

Components can no longer be imported through "@angular/material". Use the individual secondary entry-points, such as @angular/material/button.

This means that:

import { MatInputModule, MatCardModule } from "@angular/material";


import { MatInputModule } from "@angular/material/input";
import { MatCardModule } from "@angular/material/card";

First steps with Angular 8, angular-cli and Angular Material, To create a new workspace and an initial App project: ng new Step 4: Import the Angular Material component modules. I'm not sure which  Install Angular Material and it’s Dependencies. Once the project is created we can now install additional node_modules to our project. Angular IDE has a terminal view from which we can execute commands, so from the menu select Window, then Show view then click Terminal+. In the opened terminal type the following commands to install HammerJS, Angular Animations, Angular Material and Angular CDK.

Import all Angular Material modules in Angular 9.

Create material.module.ts file in your_project/src/app/ directory and paste this code.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatButtonModule } from '@angular/material/button';
import { MatInputModule } from '@angular/material/input';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatRadioModule } from '@angular/material/radio';
import { MatSelectModule } from '@angular/material/select';
import { MatSliderModule } from '@angular/material/slider';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatMenuModule } from '@angular/material/menu';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatBadgeModule } from '@angular/material/badge';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatListModule } from '@angular/material/list';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatCardModule } from '@angular/material/card';
import { MatStepperModule } from '@angular/material/stepper';
import { MatTabsModule } from '@angular/material/tabs';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatChipsModule } from '@angular/material/chips';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatDialogModule } from '@angular/material/dialog';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatTableModule } from '@angular/material/table';
import { MatSortModule } from '@angular/material/sort';
import { MatPaginatorModule } from '@angular/material/paginator';

@NgModule( {
    imports: [

    exports: [
    providers: [
} )

export class AngularMaterialModule { }

How to Install Angular Material in Angular 9?, Update 2019-July-24th: The process didn't change from Angular 7, but I have updated the application using the Angular-cli (command line tool), and Angular Material. So now you can go to the project folder: In your IDE navigate to the file “src/app/app.module.ts”, and import the following modules: How you should import MDB Angular modules: In 6.1.0 we have made it possible to import only those modules that you actually use in your application.

Getting Started With Angular Material, If you have an existing Angular Project, Open Terminal/Command Prompt in the import {MatSliderModule} from '@angular/material/slider';. $ ng new angular-material-loaders $ cd angular-material-loaders # Install Angular Material in project. After version 8, Angular Material package can be installed by executing the following ng command. For configuration, it will ask a few questions related to the theme, browser animations etc $ ng add @angular/material. Answer questions

Getting Started With Angular Material 2, Project Creation; Angular Material Installation; Creating Material Module After the installation, we are going to import it as a first-line in the  How to setup Angular 10 project with Angular Material 10 using VS Code. Please comment if you face any issue. I will be happy to solve them. Please subscribe and comment to get upcoming tutorials.

angular-material, MaterialModule has therefore been deprecated in favor of defining a project-​specific custom material module where you import and export only  For the complete navigation and all the basic instructions of the Angular Material series, check out: Introduction of the Angular Material series. The source code is available at GitHub Getting Started With Angular Material – Source Code. We are going to divide this post into several sections: Project Creation; Angular Material Installation

  • I did that, as you can see there is an sample with import { MaterialModule} from '@angular/material here
  • I dont see that in the page
  • Yes, therfore I ask how to import all modules
  • Ill add an answer, I think you might be looking at an old, cached documentation page or similar...
  • Great Answer Rijo. & very timely indeed! Got a quick question that bugs me for some time. It's not a big deal but I'm just curious. See the ./ in the import { MaterialModule } from './material.module'? I was told that ./ means the current directory. But why do we need it? Don't we assume that anyway when / or ../ is not in use in the path anyway? An HTML example to this would be that we never do this: <a href='./index2.htm'></a> when hitting the index2.htm from index.htm if both are in the same directory. See what I mean?
  • It would be realy nice if there is some kind of automated generator / validator / cleanup for the material-import.module.ts Ok i understand the how it works, and i have my "version" setup and copy it from project to project, and it has "filled up" over the time. But removing unused Modules (review by hand all templates) is not what i often do. So the new import has no advantage to the old / deprecated but complete MaterialModule ...
  • For Angular library, there is no app.module, how about this case?
  • Unfortunately it doesn't work when compiling with --prod option
  • What version of Angular?
  • Posted this when I was on Angular 5.2.0, using this package:
  • How to install this with this webpack?…
  • Should not they have fixed this first before this breaking change?
  • Add just the required modules which is required. Yes to maintain a separate module is good. But just import only the required one's.
  • Thanks for this list. I could not understand why none of the Internet tutorials about Material wouldn't work with Angular 9.1. After changing them in line with your list, they do now work.