Search code examples
cssangular-materialangular-material-table

Vertical scroll bar and fixed headers with mat-table


I would like to know how to display a vertical scroll bar for the rows only (headers are not moving) with Angular Material mat-table. When I set overflow: auto and max-height in mat-table style, the whole table (including the headers) are scrolled. Thanks for your help.


Solution

  • You may use the sticky property of MatHeaderRowDef:

    <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>