Home  >  Angular  >  Angular Material

Angular Material List with Checkbox

By Arvind Rai, April 03, 2021
Angular material provides selection list using mat-selection-list and mat-list-option. The list options are displayed with checkbox and its label. The selection of list can be single or multiple. We can also display a list option as selected or disabled.
To work with Material List we need to import MatListModule in application module.
import { MatListModule } from '@angular/material/list'; 
Here on this page, we will create Material list example with checkbox in detail.

Technologies Used

Find the technologies being used in our example.
1. Angular 11.0.3
2. Angular Material 11.2.0
3. Node.js 12.5.0
4. NPM 6.9.0


The MatSelectionList is Angular Material list directive that creates a list where each item is selectable option. For each item there will be a checkbox to select it. The selector of MatSelectionList is mat-selection-list.
Find the properties of mat-selection-list.
color: Theme color of the selection list. This color will be applicable to all checkbox of list options.
disableRipple: Boolean value to enable/disable ripple.
disabled: Boolean value to enable/disable selection list.
multiple: Boolean value to enable/disable multiple selections. If the value of multiple property is false, then only single selection can be done. By default, multiple selection can be done.
compareWith: (o1: any, o2: any): The function used for comparing an option against selected value to determine which option should appear as selected.
selectionChange: Event that emits whenever the selected state of an option changes.

Find the sample code.


The MatListOption directive creates list option within a selection list. The selector for MatListOption is mat-list-option. The mat-list-option is used within mat-selection-list.
Find the properties of mat-list-option.
checkboxPosition: Position of checkbox against label. Values can be 'before' and 'after'. The default is 'after'.
color: Theme color of the checkbox of list option.
disableRipple: Boolean value to enable/disable ripple.
disabled: Boolean value to enable/disable list option.
selected: Boolean value to display list option selected.
value: Value of the list option.

Find the sample code.

Complete Example

<h3>Material List</h3>
<mat-selection-list color="primary" (selectionChange)="onListSelectionChange($event)">
  <mat-list-option [selected]="isSelected">Varanasi</mat-list-option>
  <mat-list-option disabled="true">Noida</mat-list-option>

<h3>Material List with Reactive Form</h3>
<form [formGroup]="techForm" (ngSubmit)="onFormSubmit()">
  <mat-selection-list formControlName="selectedTech">
    <mat-list-option *ngFor="let tech of techList" [value]="tech">
  <button mat-raised-button color="warn">Submit</button>
import {Component} from '@angular/core';
import { MatSelectionListChange } from '@angular/material/list';
import { FormBuilder } from '@angular/forms';

  selector: 'app-root',
  templateUrl: 'app.component.html'
export class AppComponent {
  isSelected = true;
  onListSelectionChange(ob: MatSelectionListChange) {
     console.log("Selected Item: " + ob.source.selectedOptions.selected.length);
  techList = [
    {id: 101, lang: 'Java'},
    {id: 102, lang: 'Angular'},
    {id: 103, lang: 'Hibernate'}
  constructor(private formBuilder: FormBuilder) { }
  techForm = this.formBuilder.group({
    selectedTech: ''
  onFormSubmit() {
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ReactiveFormsModule } from '@angular/forms';
import { MatListModule } from '@angular/material/list';
import { MatButtonModule } from '@angular/material/button';

import { AppComponent } from './app.component';

  declarations: [
  imports: [
  providers: [],
  bootstrap: [AppComponent]
export class AppModule { } 

Run Application

To run the application, find the steps.
1. Install Angular CLI using link.
2. Install Angular Material using link.
3. Download source code using download link given below on this page.
4. Use downloaded src in your Angular CLI application.
5. Run ng serve using command prompt.
6. Access the URL http://localhost:4200
Find the print screen of the output.
Angular Material List with Checkbox


Angular Material List

Download Source Code


©2022 concretepage.com | Privacy Policy | Contact Us