Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase gap between mat rows in mat-table angular

My table:

<mat-table  [dataSource]="dataSource" >
        
    <!-- Position Column -->
    <ng-container matColumnDef="Customer">
      <mat-header-cell *matHeaderCellDef > CUSTOMER </mat-header-cell>
      <mat-cell *matCellDef="let element" > {{element.Customer}} </mat-cell>
    </ng-container>
    
 
    <!-- Name Column -->
    <ng-container matColumnDef="Origin">
      <mat-header-cell *matHeaderCellDef> ORIGIN </mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.Origin}} </mat-cell>
    </ng-container>
 
    <ng-container matColumnDef="Destination">
      <mat-header-cell *matHeaderCellDef> DESTINATION </mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.Destination}} </mat-cell>
    </ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns;sticky: true"></mat-header-row>
    <mat-row *matRowDef="let row; columns: displayedColumns;" ></mat-row>
  </mat-table>

CSS:

.mat-table {
border-collapse: separate;
border-spacing:04px;
}

What I'm getting:

[---MAT-ROW---]
[---MAT-ROW---]
[---MAT-ROW---]
[---MAT-ROW---]

What I need:

[---MAT-ROW---]

[---MAT-ROW---]

[---MAT-ROW---]

Tried to add border spacing to mat-table....also added border-collapse...still not working.

can anyone help me with this. Thanks...!

like image 430
bollam_rohith Avatar asked Apr 12 '26 23:04

bollam_rohith


1 Answers

Use the below css.

.mat-table {
    overflow-x: scroll;
    max-width: 99%;
  }
  
  .mat-cell,
  .mat-header-cell {
    word-wrap: initial;
    display: table-cell;
    padding: 0px 10px;
    line-break: unset;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    vertical-align: middle;
  }
  
  .mat-row,
  .mat-header-row {
    display: table-row;
  }
like image 96
surendra kumar Avatar answered Apr 16 '26 00:04

surendra kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!