Table
mat-table is a flexible data table component with sorting and pagination.
Basic Table
mat-table displaying periodic elements with static data.
| No. | Name | Weight | Symbol |
|---|---|---|---|
| 1 | Hydrogen | 1.0079 | H |
| 2 | Helium | 4.0026 | He |
| 3 | Lithium | 6.941 | Li |
| 4 | Beryllium | 9.0122 | Be |
| 5 | Boron | 10.811 | B |
| 6 | Carbon | 12.0107 | C |
| 7 | Nitrogen | 14.0067 | N |
| 8 | Oxygen | 15.9994 | O |
| 9 | Fluorine | 18.9984 | F |
| 10 | Neon | 20.1797 | Ne |
HTML
TS
<table mat-table [dataSource]="dataSource" class="w-full">
<ng-container matColumnDef="position">
<th mat-header-cell *matHeaderCellDef>No.</th>
<td mat-cell *matCellDef="let e">{{ e.position }}</td>
</ng-container>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Name</th>
<td mat-cell *matCellDef="let e">{{ e.name }}</td>
</ng-container>
<ng-container matColumnDef="weight">
<th mat-header-cell *matHeaderCellDef>Weight</th>
<td mat-cell *matCellDef="let e">{{ e.weight }}</td>
</ng-container>
<ng-container matColumnDef="symbol">
<th mat-header-cell *matHeaderCellDef>Symbol</th>
<td mat-cell *matCellDef="let e">{{ e.symbol }}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let r; columns: displayedColumns;"></tr>
</table>Sortable & Paginated Table
mat-table with matSort and mat-paginator for interactive sorting and page navigation.
No. | Name | Weight | Symbol |
|---|---|---|---|
| 1 | Hydrogen | 1.0079 | H |
| 2 | Helium | 4.0026 | He |
| 3 | Lithium | 6.941 | Li |
| 4 | Beryllium | 9.0122 | Be |
| 5 | Boron | 10.811 | B |
| 6 | Carbon | 12.0107 | C |
| 7 | Nitrogen | 14.0067 | N |
| 8 | Oxygen | 15.9994 | O |
| 9 | Fluorine | 18.9984 | F |
| 10 | Neon | 20.1797 | Ne |
5
0 of 0
HTML
TS
<table mat-table [dataSource]="dataSource" matSort class="w-full">
<ng-container matColumnDef="position">
<th mat-header-cell *matHeaderCellDef mat-sort-header>No.</th>
<td mat-cell *matCellDef="let e">{{ e.position }}</td>
</ng-container>
<!-- ... additional columns ... -->
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let r; columns: displayedColumns;"></tr>
</table>
<mat-paginator
[pageSizeOptions]="[5, 10]"
[showFirstLastButtons]="true"
aria-label="Table paginator"
></mat-paginator>