23.01.2023 ... MatTable which is build on top of CdkTable is using internally @ContentChildren() decorator to get all cdkColumnDef (in this case ......
In the realm of web development, presenting data in an organized and user-friendly manner is paramount. Angular Material's table component, MatTable, is a powerful tool that enables you to create responsive and dynamic tables with ease. In this article, we'll delve into the world of Angular MatTable templates, exploring its key features, setup, and best practices.
Angular Material's MatTable is a robust table component that allows you to display data in a structured format. It's built on top of the Angular CDK (Component Dev Kit) and provides a wide range of customization options, making it an excellent choice for displaying complex data sets.
Before we dive into creating MatTable templates, let's ensure you have Angular Material set up in your project.

First, install Angular Material and its peer dependencies using npm:
npm install --save @angular/material @angular/cdk @angular/animations
Then, import the necessary modules in your AppModule:
import { MatTableModule } from '@angular/material/table';
import { CdkTableModule } from '@angular/cdk/table';
@NgModule({
imports: [
// ...
MatTableModule,
CdkTableModule
],
// ...
})
export class AppModule { }
Now that we have Angular Material set up, let's create a simple MatTable template.

MatTable requires a data source to display data. You can use a simple array or implement a data source interface like DataSource or MatTableDataSource.
The MatTable component's template structure is quite straightforward. Here's a basic example:
| Template Structure | Description |
|---|---|
<table mat-table [dataSource]="dataSource"> |
The MatTable component. The dataSource input binds to your data source. |
<ng-container matColumnDef="column1"></ng-container> |
Defines a column. The column name should match the property name in your data. |
<tr mat-header-row *matHeaderRowDef="displayedColumns"> |
Renders the table header. The displayedColumns input is an array of column names to display. |
<tr mat-row *matRowDef="let row; columns: displayedColumns;"> |
Renders a table row. The matRowDef directive tells MatTable how to render each row. |
MatTable templates can be customized to fit your application's needs. You can add buttons, icons, or even entire components to your table cells. Here's an example of adding a delete button to a table row:
To interact with a component inside a table cell, you'll need to use template reference variables. Here's how you can add a delete button to a table row:
<button mat-icon-button (click)="deleteRow(row)"><i class="material-icons">delete</i></button>
In this example, row is a template reference variable that references the current row data.
Here are some best practices to keep in mind when working with Angular MatTable templates:
trackBy function in your data source to improve performance.matSort directive to enable sorting on your table columns.matPaginator directive to enable pagination on your table.By following these best practices, you'll be well on your way to creating powerful and engaging data tables with Angular Material's MatTable component.
<strong>placing several common columns for angular table in an ng-template</strong><p>23.01.2023 ... MatTable which is build on top of CdkTable is using internally @ContentChildren() decorator to get all cdkColumnDef (in this case ...</p>
<strong>Angular Material UI Component Library</strong><p>UI component infrastructure and Material Design components for mobile and desktop Angular web applications.</p>
<strong>Reusable Angular Material Table in Angular 20 | by Andreea Magdici</strong><p>21.07.2025 ... To render the right custom cell, in the right place, the table component needs to know which TemplateRef is associated with a particular column.</p>
<strong>Angular Mat Table Design - StackBlitz</strong><p>Starter project for Angular apps that exports to the Angular CLI.</p>
<strong>Angular Material Data Table: A Complete Example</strong><p>23.02.2026 ... A complete example of an Angular Material Data Table with server-side pagination, sorting, filtering, as well as a loading indicator.</p>
<strong>components/src/material/table/table.ts at main - GitHub</strong><p>Component infrastructure and Material Design components for Angular - components/src/material/table/table.ts at main · angular/components.</p>
<strong>Angular Material Table Auto Layout - Figma</strong><p>i'm going to work on that @jess19. thanks xxx. Jess4 years ago. you forgot the check boxes :) Share. For Figma. Last updated 4 years ago.</p>
<strong>How to migrate to the Material Table - PlentyONE developers</strong><p>The Angular Material Table offers many useful functionalities, such as pagination or sorting. ... Then add the mat-paginator to the template. <div ...</p>
<strong>Creating a reusable angular material table - Reddit</strong><p>25.09.2020 ... I'm trying to create a reusable material mat-table where I can pass the table body into the child using a template. However it dosn't appear ...</p>
<strong>Angular Material Dev UI</strong><p>A comprehensive dashboard template featuring analytics, charts, tables, and responsive design. Built with the latest Angular Material components and best ...</p>
<strong>Dynamically render columns in Angular material table</strong><p>02.07.2024 ... You can dynamically render columns in angular material table. No, I am not talking about simply adding/removing columns on click of button, but a more robust ...</p>
<strong>Angular Material Table: A Complete Guide with Best Example</strong><p>25.06.2024 ... We'll dive into Angular Material tables in this blog article, covering various table kinds, creating and customizing them, and implementing advanced features ...</p>
<strong>1. Write your mat-table and provide data - Angular Material</strong><p>Next, write your table's column templates. Each column definition should be given a unique name and contain the content for its header and row cells. Here's a ...</p>
<strong>Creating a Dynamic View and Material Table in Angular - Medium</strong><p>07.03.2020 ... MatTable Template. First, let's look at how we're going to define the MatTable in the template through a quick compare and contrast. Hard ...</p>
<strong>Type-safe MatCellDef - Chau Tran</strong><p>19.03.2021 ... ... MatTable does have to leverage the Dynamic Template system of Angular. ... import { MatCellDef, MatTableDataSource } from "@angular/material/table ...</p>
<strong>How to Add Custom Columns manually to Angular Material Table ...</strong><p>01.02.2021 ... https://codedocu.com/Net-Framework/ASP_dot_Net-Core/Angular/Material/Angular-Material-Table_colon_-Insert-manual-columns?2684 how to add a ...</p>
<strong>Angular Material: table - Rob Ferguson</strong><p>13.12.2019 ... In this post, I take a look at Angular Material's table component. Layout. The Material Design website includes a great introduction to layout.</p>
<strong>create a material looking table (withOUT dataTable) #3805 - GitHub</strong><p>27.03.2017 ... I already used the angular material table with datasource. Not ... angular traditional template using. Look here: The Sort Example ...</p>
<strong>Mat-Table inside a MAt-Table shows extra row for every record</strong><p>multiTemplateDataRows width="100%">. <!--- Note that these columns can be ... to Angular and AngularJS discussion. I solved this by adding CSS file.</p>
<strong>Angular mat-table sort example: Adding sorting to the material table</strong><p>In this tutorial we will learn how to sort a mat-table in Angular. With the help of MatSortModule we can add sorting to mat-table in Angular.</p>