Skip to content
Related Articles

Related Articles

<mat-button> in Angular material

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 25 Nov, 2020
Improve Article
Save Article

Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. 

In order to use it, we need to have angular installed in our project, after having it you can enter the below command and can download it.

Installation syntax:

ng add @angular/material

Types of Buttons in Angular material: Buttons present in angular material are called as <mat-button>. They are many types of mat-buttons available in angular material, they are:

Button Name

The tag used for the buttons


 Basic Buttons


These are the normal default button

Raised Buttons


These buttons appear to be raised i.e., they have a kind of box-shadow

 Stroked buttons


These buttons don’t have any background theme color.

Flat Buttons


These buttons are very flat i.e. they don’t have any kind of animation and only have a ripple effect.

Fab Buttons


These buttons are circular buttons.

Mini Fab Buttons


These buttons are also circular but compared to fab buttons they are small.


  • First, install the angular material using the above-mentioned command.
  • After completing the installation, Import ‘MatButtonModule’ from ‘@angular/material/button’ in the app.module.ts file.
  • Then using the above-mentioned tags in the table code all types of buttons.
  • If we want to change the theme then we can change it by using the color property. In angular we have 3 themes, they are primary, accent, and warn.
  • Once done with the above steps then serve or start the project.

Code Implementation: In this example, we will implement all types of <mat-button> in angular.



import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MatButtonModule} from '@angular/material/button';
  imports:      [ BrowserModule, 
                  MatButtonModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
export class AppModule { }



<h5>Basic Buttons</h5>
  <button mat-button>Basic</button>
  <button mat-button color="primary">Primary</button>
  <button mat-button color="accent">Accent</button>
  <button mat-button color="warn">Warn</button>
  <button mat-button disabled>Disabled</button>
<h5>Raised Buttons</h5>
  <button mat-raised-button>Basic</button>
  <button mat-raised-button color="primary">Primary</button>
  <button mat-raised-button color="accent">Accent</button>
  <button mat-raised-button color="warn">Warn</button>
  <button mat-raised-button disabled>Disabled</button>
<h5>Stroked Buttons</h5>
  <button mat-stroked-button>Basic</button>
  <button mat-stroked-button color="primary">Primary</button>
  <button mat-stroked-button color="accent">Accent</button>
  <button mat-stroked-button color="warn">Warn</button>
  <button mat-stroked-button disabled>Disabled</button>
<h5>Flat Buttons</h5>
  <button mat-flat-button>Basic</button>
  <button mat-flat-button color="primary">Primary</button>
  <button mat-flat-button color="accent">Accent</button>
  <button mat-flat-button color="warn">Warn</button>
  <button mat-flat-button disabled>Disabled</button>
<h5>Fab Buttons</h5>
  <button mat-fab>Basic</button>
  <button mat-fab color="primary">Primary</button>
  <button mat-fab color="accent">Accent</button>
  <button mat-fab color="warn">Warn</button>
  <button mat-fab disabled>Disabled</button>
<h5>Mini Fab Buttons</h5>
  <button mat-mini-fab>Basic</button>
  <button mat-mini-fab color="primary">Primary</button>
  <button mat-mini-fab color="accent">Accent</button>
  <button mat-mini-fab color="warn">Warn</button>



My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!