Skip to content

Angular Material

UI & GraphicsUI FrameworkJavaScript

What it is

Angular Material is the official UI component library for Angular, built with Google's Material Design system. It provides a wide range of reusable, accessible, and customizable UI components.

Angular Material provides Angular components for navigation, forms, buttons, dialogs, data tables, and more. Components follow Angular’s modular structure and are imported as individual modules.

Installation

npm install @angular/material @angular/cdk @angular/animations

Getting started

The smallest useful thing you can do with it, and what each part means.

Button usage
import { MatButtonModule } from '@angular/material/button';

@NgModule({
  imports: [MatButtonModule]
})
export class AppModule {}

<button mat-raised-button color="primary">Click Me</button>
Imports the `MatButtonModule` and uses a raised Material Design button.
Input field
import { MatInputModule } from '@angular/material/input';

<mat-form-field appearance="fill">
  <mat-label>Email</mat-label>
  <input matInput placeholder="Enter your email">
</mat-form-field>
Creates a Material-styled input field with a floating label.

Advanced usage

Where the library earns its place over a simpler alternative.

Dialog component
import { MatDialog } from '@angular/material/dialog';

constructor(public dialog: MatDialog) {}

openDialog() {
  this.dialog.open(DialogContentExampleDialog);
}

@Component({
  selector: 'dialog-content-example-dialog',
  template: `<h1 mat-dialog-title>Dialog</h1>
             <div mat-dialog-content>This is a Material dialog</div>
             <div mat-dialog-actions>
               <button mat-button mat-dialog-close>Close</button>
             </div>`
})
export class DialogContentExampleDialog {}
Shows how to create and open a Material Design dialog in Angular.
Data Table
import { MatTableModule } from '@angular/material/table';

<mat-table [dataSource]="data">
  <ng-container matColumnDef="name">
    <mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
    <mat-cell *matCellDef="let element">{{element.name}}</mat-cell>
  </ng-container>
  <mat-header-row *matHeaderRowDef="['name']"></mat-header-row>
  <mat-row *matRowDef="let row; columns: ['name'];"></mat-row>
</mat-table>
Implements a simple Angular Material data table.

Errors and fixes

The failures you are most likely to hit, and what actually resolves them.

Material components not styled
Ensure you imported a prebuilt theme CSS (e.g., `@angular/material/prebuilt-themes/indigo-pink.css`).
Animations not working
Import `BrowserAnimationsModule` in your `AppModule`.
Build errors when importing modules
Make sure you’re importing Angular Material modules in the correct `NgModule`.

Best practices

  • Import only the Angular Material modules you need to reduce bundle size.
  • Use Angular Material’s theming system to maintain consistent branding.
  • Combine Material components with Angular Reactive Forms for powerful form handling.
  • Enable animations (`BrowserAnimationsModule`) for full Material Design experience.
  • Follow Angular Material accessibility guidelines to ensure inclusive apps.

Background

Why it exists, and what it was reacting to.

Angular Material was created by the Angular team at Google to bring the Material Design language to Angular applications. It ensures consistency, accessibility, and integration with Angular’s ecosystem, making it a standard choice for enterprise-grade Angular projects.