Angular material - table - change column width

Viewed 8919

is there any way how to set different width for column ?

After many tries, it seems columns are even, ignoring all styles.

2 Answers

yes, it is possible using css .mat-column-<matColumnDef-value>, suppose you have a column def "group" like:

<!-- Group Column -->
<ng-container matColumnDef="group">
  <mat-header-cell *matHeaderCellDef mat-sort-header>Group</mat-header-cell>
  <mat-cell *matCellDef="let element">
    {{element.group}}
  </mat-cell>
</ng-container>

In the css you can set the width:

.mat-column-group {
  width: 150px;
  max-width: 150px;
}

this is awkward, it is not possible to override styles by width... min-width has to be applied.

Related