![]() |
VOOZH | about |
Angular Material is a UI component library 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-list>is a directive in Angular Material that acts as a container component, which wraps the list of <mat-list-item>in it. Angular Material provides different types of list formats, which are described below:
Syntax:
<mat-list>
<mat-list-item>Sample list item</mat-list-item>
...
</mat-list>
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. The following command is executed on the Angular CLI to install the angular material library:
ng add @angular/materialMake sure the path should be opened in the terminal before executing the above command.
Please refer to the Adding Angular Material Component to Angular Application article for the detailed installation procedure.
Adding List Component: To use the List Component, we need to import it into the app.module.ts file:
import { MatListModule } from '@angular/material/list';To use the list component in our code we have to import MatListModule into the imports array.
Project Structure: After successful installation, the project structure will look like the following image:
Example 1: This example describes the basic usage of the Angular Material List by implementing the Navigation List.
Output:
Example 2: This example describes the basic usage of the Simple list, Action List & Selection list in Angular Material.
Output:
Reference: https://material.angular.dev/components/list/overview