PrimeNG – How to change the style of pTemplate=”caption” in p-table for a single component

pTemplate="caption" will only fit part of your table header, you have to work on p-datatable-header class:

Try this:

:host ::ng-deep {
  #myTable {
    .p-datatable-header {
      background-color: red;
    }
  }
}

I surrounded p-datatable-header class with #myTable to apply this CSS only for a table with myTable id:

<p-table id="myTable" [value]="products">

See StackBlitz

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top