matBadge in angular-material Last Updated : 19 Jan, 2021 Suggest changes Share 1 Likes Like Report 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 install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it. The main use of the matBadge and assign a value in order to display numbers or status over text or images or icons. We can relate to them as a notification icon number indicator. Installation syntax: ng add @angular/material Approach: First, install the angular material using the above-mentioned command.After completing the installation, Import ‘MatBadgeModule’ from ‘@angular/material/badge’ in the app.module.ts file.Then use matBadge and assign a number to display it over any text or image.We also have other properties like matBadgeOverlap and matBadgeSize in-order to customizes the badge size and position.If we want to change the theme then we can change it by using the matBadgeColor 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: app.module.ts: JavaScript import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { MatBadgeModule} from '@angular/material/badge'; import { MatIconModule} from '@angular/material/icon'; import { MatButtonModule} from '@angular/material/button'; @NgModule({ imports: [ BrowserModule, FormsModule, MatButtonModule, MatBadgeModule, MatIconModule ], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export class AppModule { } app.component.html: HTML <h3> Mat-Badge over a text</h3> <p> <span matBadge="8" matBadgeOverlap="false"> Text with a badge </span> </p> <hr> <h3> Mat-Badge positioned left and right over a Button </h3> <p> <button mat-raised-button color="primary" matBadge="8" matBadgePosition="before" matBadgeColor="accent"> Left badge Button with accent theme </button> </p> <p> <button mat-raised-button color="accent" matBadge="8" matBadgePosition="after" matBadgeColor="primary"> Right badge button with primary theme </button> </p> <hr> <h3> Mat-Badge over a icon</h3> <p> <mat-icon matBadge="8" matBadgeColor="warn"> home </mat-icon> </p> Output: B bunnyram19 Follow 1 Article Tags : Web Technologies AngularJS AngularJS-Misc Material-UI Explore AngularJS BasicsAngularJS Tutorial 5 min read Introduction to AngularJS 4 min read Angular CLI | Angular Project Setup 3 min read AngularJS Expressions 2 min read AngularJS Modules 3 min read AngularJS ng-model Directive 4 min read AngularJS Data Binding 4 min read AngularJS Controllers 3 min read AngularJS | Scope 2 min read AngularJS Services 4 min read AngularJS | AJAX - $http 3 min read AngularJS | Tables 2 min read AngularJS Select Boxes 2 min read AngularJS SQL 3 min read AngularJS HTML DOM 2 min read AngularJS Events 3 min read AngularJS | Forms 3 min read AngularJS Form Validation 3 min read AngularJS | API 2 min read AngularJS and W3.CSS 2 min read AngularJS Includes 3 min read AngularJS Animations 1 min read AngularJS | Application 3 min read AngularJS DirectivesAngularJS Directives 9 min read AngularJS ng-app Directive 1 min read AngularJS ng-bind Directive 2 min read AngularJS ng-bind-html Directive 2 min read AngularJS ng-bind-template Directive 2 min read AngularJS ng-blur Directive 1 min read AngularJS ng-change Directive 2 min read AngularJS ng-checked Directive 2 min read AngularJS ng-class Directive 2 min read AngularJS ng-class-even Directive 2 min read AngularJS ng-class-odd Directive 2 min read AngularJS ng-click Directive 2 min read AngularJS ng-cloak Directive 2 min read AngularJS ng-controller Directive 2 min read AngularJS Directives Complete Reference 2 min read AngularJS FiltersAngularJS | Filters 7 min read AngularJS currency Filter 2 min read AngularJS | date Filter 2 min read AngularJS filter Filter 3 min read AngularJS json Filter 2 min read AngularJS limitTo Filter 2 min read AngularJS lowercase Filter 1 min read AngularJS number Filter 1 min read AngularJS orderBy Filter 4 min read AngularJs uppercase Filter 1 min read AngularJS Converting FunctionsAngularJS angular.lowercase() Function 2 min read AngularJS angular.uppercase() Function 1 min read AngularJS angular.forEach() Function 1 min read AngularJS Comparing FunctionsAngularJS angular.isArray() Function 2 min read AngularJS angular.isDate() Function 2 min read AngularJS angular.isDefined() Function 2 min read AngularJS angular.isElement() Function 2 min read AngularJS angular.isFunction() Function 2 min read AngularJS angular.isNumber() Function 2 min read AngularJS angular.isObject() Function 2 min read AngularJS | angular.isString() Function 1 min read AngularJS angular.isUndefined() Function 2 min read AngularJS angular.equals() Function 2 min read AngularJS angular.toJson() Function 2 min read AngularJS QuestionsHow to bundle an Angular app for production? 4 min read How to add many functions in one ng-click directive? 2 min read How to directly update a field by using ng-click in AngularJS ? 3 min read How to Add Dynamic Options for Multiple Selects Inside ng-repeat Directive ? 3 min read How to detect when an @Input() value changes in Angular? 3 min read How to open popup using Angular and Bootstrap ? 2 min read How to reload or re-render the entire page using AngularJS? 2 min read How to add input fields dynamically on button click in AngularJS ? 2 min read How to Create Button Dynamically with Click Event in Angular ? 2 min read How to use jQuery in Angular ? 2 min read AngularJS Examples 2 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like