My mat-table has a basic column structure like this:
<mat-table #table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="zone">
<mat-header-cell *matHeaderCellDef mat-sort-header></mat-header-cell>
<mat-cell *matCellDef="let item" [style.background-color]="'#' + item.zone.color"></mat-cell>
</ng-container>
...
</mat-table>
I'm looking to assign different colors to the cells in the 'zone' column, row by row.
Although I've managed to color entire rows, I want to target only the cells in the 'zone' column.
The HTML output for the zone
column cells looks like this:
<mat-cell class="mat-cell cdk-column-zone mat-column-zone" role="gridcell" style="background-color: rgb(255, 182, 193);" _ngcontent-c8=""></mat-cell>
While the background-color
style is applied correctly, the issue lies in the cell's height being 0 since there is no content. Even inserting an
results in a thin bar with margins:
https://i.sstatic.net/faVto.jpg
My goal is to color the entire cell along with its margins. How can individual cells be colored in a mat-table?