Pavel Franta
Pavel Franta

Reputation: 1313

Angular material - table - change column width

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

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

Upvotes: 5

Views: 14846

Answers (2)

Ibrahim El_Khatib
Ibrahim El_Khatib

Reputation: 483

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;
}

Upvotes: 8

Pavel Franta
Pavel Franta

Reputation: 1313

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

Upvotes: 0

Related Questions