Open In App
Related Articles

Angular Material Toolbar Component

Improve Article
Save Article
Like Article

Angular Material is a UI component library which is developed by Google so that Angular developers can develop modern applications in a structured and responsive way. By making use of this library, we can greatly increase the user experience of an end-user thereby gaining popularity for our application. This library contains modern ready-to-use elements which can be directly used with minimum or no extra code.

The <mat-toolbar> is a container for headers, titles, or actions. In Angular material, the toolbar is placed at the top of the application that may include the title or some action in the specific position of an application. The toolbar can be of a single row or multiple rows, depending on the specific requirement. Creating the toolbar with a single row can be accomplished with <mat-toolbar> & </mat-toolbar> tags. For creating the toolbar with multiple rows, we can place the <mat-toolbar-row> elements inside of a <mat-toolbar>.


<mat-toolbar> Content </mat-toolbar>

Installation Syntax:

The basic pre-requisite is that we must have Angular CLI installed on the system in order to add and configure the Angular material library. After satisfying the required condition, we can type the following command on the Angular CLI:

ng add @angular/material

Please refer to the Adding Angular Material Component to Angular Application article for the detailed installation procedure.

Adding Toolbar component:

To use the toolbar component, we need to import it into the module.ts file. 

import { MatToolbarModule } from '@angular/material/toolbar';

Then, we need to add this component into our imports array. After this, we can use it in our code.

Project Structure:

After successful installation, the project structure will look like the following image:

Project Structure

Example: The below example illustrates the implementation of the Angular Material Toolbar.


import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { MatToolbarModule } from "@angular/material/toolbar";
import { BrowserModule } from "@angular/platform-browser";
import { AppComponent } from "./app.component";
import { BrowserAnimationsModule } 
      from "@angular/platform-browser/animations";
import { MatIconModule } from "@angular/material/icon";
  declarations: [AppComponent],
  exports: [AppComponent],
  imports: [
  bootstrap: [AppComponent],
export class AppModule {}


import { Component } from '@angular/core';
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
export class AppComponent  {}


<mat-toolbar class="title-toolbar">
    <span class="title-center">GeeksforGeeks</span>
    <span class="example-spacer"></span>
    <mat-icon class="example-icon" 
    <span>Contribute Article</span>
    <span class="example-spacer"></span>
      aria-label="Write article">create
      aria-label="Login or Register">


@import "~material-icons/iconfont/material-icons.css";
.example-icon {
  padding: 0 14px;
.example-spacer {
  flex: 1 1 auto;
.title-center {
  margin: 0 auto;
  color: white;
.title-toolbar {
  background: green;


Angular Material Toolbar Component

Angular Material Toolbar


Last Updated : 16 Jan, 2022
Like Article
Save Article
Similar Reads
Related Tutorials