Ruben Szekér
Ruben Szekér

Reputation: 1175

Angular Material: equal styling for mat-sort-headers and non mat-sort-headers

I recently noticed that my column headers are not aligned horizontally. I figured out what causes it, but I don't know how to fix it exactly.

What I currently have

Situation as is

This is currently so because the HTML contains the following code

<ng-container matColumnDef="Status">
   <mat-header-cell *matHeaderCellDef mat-sort-header="Status">
     Status
     ... <!-- Unimportant information -->
   </mat-header-cell>
     ... <!-- Unimportant information -->
</ng-container>
<ng-container matColumnDef="Actions">
   <mat-header-cell *matHeaderCellDef> <!-- Notice how mat-sort-header is not present, this causes the visual issue -->
     Acties
   </mat-header-cell>
    ... <!-- Unimportant information -->
</ng-container>

What I want to achieve

What I want to achieve

Is easily doable by adding mat-sort-header="Status" to the Acties HTML code. However, this causes another issue, being the following error message (see image 3).

Error caused by adding mat-sort-header="Status"

What I tried already

Upvotes: 0

Views: 883

Answers (1)

QT Ray
QT Ray

Reputation: 1424

Can you do a /deep/ styling selector and give the "acties" a class or id and target it with the rule you need?

/deep/ mat-header-cell.acties {
// your rules here
}

Upvotes: 1

Related Questions