Sticky header not working with resizable column in Primeng.?

when you set the p-table columns to be resizable the add a class ui-table-resizable this will reset some css property one of its the position of th to relative so you will lose sticky future

this should fix the problem

:host ::ng-deep .ui-table .ui-table-thead > tr > th {
  position: -webkit-sticky;
  position: sticky;
  background: blue;
  color: white;
  top: 0px;
  z-index: 1;
}

:host ::ng-deep .ui-table-resizable > .ui-table-wrapper {
  overflow-x: initial !important;
}

:host ::ng-deep .ui-table-resizable .ui-resizable-column {
  position: sticky !important;
}

@media screen and (max-width: 64em) {
  :host ::ng-deep .ui-table .ui-table-thead > tr > th {
    top: 0px;
  }
}

demo 🔥🔥

Updated! 🚀🚀

add the style in the component decorator is not reusable ,base of primeng theme recommendation of creating custom style we can do like this

style.scss

.sticky-table {

      &.ui-table .ui-table-thead > tr > th {
        position: -webkit-sticky;
        position: sticky !important;
        background: blue;
        color: white;
        top: 0px;
        z-index: 1;
      }

     &.ui-table-resizable > .ui-table-wrapper {
        overflow-x: initial !important;
      }

      &.ui-table-resizable .ui-resizable-column {
        position: sticky !important;
      }

      @media screen and (max-width: 64em) {
        .ui-table .ui-table-thead > tr > th {
          top: 0px;
        }
      }

}

template

<p-table styleClass="sticky-table" [columns]="cols" [value]="cars [resizableColumns]="true">
....
</p-table>

demo ⚡⚡


:host ::ng-deep .p-datatable .p-datatable-thead > tr > th {
        position: -webkit-sticky;
        position: sticky;
        background: blue;
        color: white;
        top: 0px;
        z-index: 1;
      }
      
      :host ::ng-deep .p-datatable-resizable > .p-datatable-wrapper {
        overflow-x: initial !important;
      }
      
      :host ::ng-deep .p-datatable-resizable .ui-resizable-column {
        position: sticky !important;
      }
      
      @media screen and (max-width: 64em) {
        :host ::ng-deep .p-datatable .p-datatable-thead > tr > th {
          top: 0px;
        }
      }

Anyone who still might be interested:
For me it worked by just adding the following

:host ::ng-deep .p-datatable .p-datatable-wrapper {
    overflow-x: initial;
}

The Resizable-Fatures adds "overflow-x: auto" to the table, which hides the stick header.