e.preventDefault(); // Prevent form submission input.blur(); // remove focus input.value = ""; // optional: clear the input

Getting Started With Angular Material

What is the angular material?

Angular Material could be a UI component library for Angular developers. Angular Material provides modern UI components that work across mobile, web and desktop. Angular Material to facilitate the development process through reusability of common components like Cards, beautiful Inputs, Data Tables, and so on.

The angular Material style could be a specification for a unified system of visual, motion, and interaction design that adapts across different devices and different screen sizes. It is creating faster, beautiful, and responsive websites.

Steps to install Angular Material:

  • Step 1: Install the Angular CLI
  • Step 2: Create a workspace for Angular Project
  • Step 3: Install Angular Material, Angular CDK and Angular Animations
  • Step 4: Configure animations
  • Step 5: Import the Angular Material component modules
  • Step 6: Gesture Support

In detail information about steps to install Angular Material:

Step 1: Install the Angular CLI

installed the Angular CLI globally using npm:

 npm install -g @angular/cli

Step 2: Create a workspace for Angular Project

To create a new workspace:

ng new angular-material-app

Step 3: Install Angular Material, Angular CDK and Angular Animations

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

Using the Angular CLI ng the add command will update your Angular project with the correct dependencies, perform configuration changes and execute initialization code.

ng add @angular/material

Step 4: Configure animations

@NgModule({
  imports: [BrowserAnimationsModule],
})

export class AppModule { }

Step 5: Import the Angular Material component modules

Imports the Angular Material component modules which you need in App.

Below are a few examples.

import { MatAutocompleteModule, MatButtonModule, MatCheckboxModule, MatDatepickerModule, 
MatFormFieldModule, MatInputModule, MatRadioModule, MatSelectModule, MatSliderModule, 
MatSlideToggleModule } from '@angular/material';

@NgModule({
imports: [
     MatAutocompleteModule,
     MatButtonModule,
     MatCheckboxModule,
     MatDatepickerModule,
     MatFormFieldModule,
     MatInputModule,
     MatRadioModule,
     MatSelectModule,
     MatSliderModule,
     MatSlideToggleModule
 ]})

Examples:

Checkbox

<mat-checkbox>Check me!</mat-checkbox>

Radio Button

<mat-radio-group>
   <mat-radio-button value="1">Male</mat-radio-button>
   <mat-radio-button value="2">Female</mat-radio-button>
</mat-radio-group>

Input

<mat-form-field class="col-12">
   <input matInput placeholder="Name" value="Tudip">
</mat-form-field>

Button

<button mat-raised-button>Click Me</button>

Card

<mat-card>Material Card</mat-card>

Outputhow to install angular material

Step 6: Gesture Support

Some components (mat-slide-toggle, mat-slider, matTooltip) rely on HammerJS for gestures.

In order to urge the complete feature-set of those elements, HammerJS should be loaded into the appliance.

 npm install hammerjs --save

Complete installing HammerJS then import it on ‘main.ts’ file

import 'hammerjs';

Read more about the Difference between Angular and React

Related Posts

Latest Posts

  • All Posts
  • Generative AI
  • manufacturing
  • News
  • Portfolio
    •   Back
    • Android
    • iOS
    • Java
    • PHP
    • MEAN
    • Ruby
    • DotNet
    • IoT
    • Cloud
    • Testing
    • Roku
    • CMS
    • Python

India

Plot No. 11/2, Phase 3, Hinjewadi Rajiv Gandhi Infotech Park, Pune, India – 411057.
info@tudip.com
+91-96-8990-0537

United States

1999 S. Bascom Ave Suite 700, Campbell CA. 95008, USA.
info@tudip.com
+1-408-216-8162

Canada

64 Caracas Road North York, Toronto Ontario M2K 1B1, Canada.
info@tudip.com

Mexico

Calle Amado Nervo #785 Interior B Colonia Ladron De Guevara 44600 Guadalajara, Jalisco, Mexico.
info@tudip.com

Colombia

Cra. 9 # 113-53 Of. 1405 Bogotá D.C., Colombia.
info@tudip.com

UAE

Tudip Information Technologies L.L.C Office No 109, ABU HAIL BUILDING 13, Abu Hail, Dubai, UAE.
info@tudip.com

Nigeria

22 Kumasi Crescent, Wuse 2, Abuja, Nigeria.
info@tudip.com