Styling Angular Material Paginator

13,298

Solution 1

Use this css(for more style open F12 and override material declaretion):

See working code

::ng-deep .mat-paginator-page-size-select {
    width: 27px!important;
}
::ng-deep .mat-form-field-appearance-legacy .mat-form-field-underline {
    background-color: transparent;
}

::ng-deep .mat-select-value {
  color: #005999;
    font-weight: bold;
    font-size: 15px;
}
::ng-deep .mat-select-arrow {
    color: #005999;
}
::ng-deep .mat-option{
  padding: 0!important;

}
::ng-deep .mat-option-text {

    text-align: right;
}

For captions modifying you should provide MatPaginatorIntl. Example

Solution 2

If you use separate style for components and you want style child component you need to use in your css style ::ng-deep before you style child component selector, for example:

::ng-deep .mat-select-value {
  border: 1px solid red!important;
}
Share:
13,298

Related videos on Youtube

Saif Ali
Author by

Saif Ali

Updated on June 04, 2022

Comments

  • Saif Ali
    Saif Ali almost 2 years

    I have an Angular Material Paginator that looks like

    enter image description here

    I want to style it and it should look like

    enter image description here

    I am having a very difficult time to style it. I was just able to move the elements in the paginator around(start and end positions), apart from this I was not able to modify anything.

    Please let me know how to do the required styling ?

    Here is the stackblitz link https://stackblitz.com/edit/angular-tjhkpo

    • לבני מלכה
      לבני מלכה over 5 years
      please share your code in stackblitz fork and show us link:stackblitz.com/edit/angular-material
    • לבני מלכה
      לבני מלכה over 5 years
      it is the only way we can help you (please put in blitz only relevant code)
    • Saif Ali
      Saif Ali over 5 years
      Here you go Link I want to style the paginator in the table as the target paginator shown in my question @לבנימלכה
    • לבני מלכה
      לבני מלכה over 5 years
      nice! add this link to question
    • Saif Ali
      Saif Ali over 5 years
      I have added the link !
  • Saif Ali
    Saif Ali over 5 years
    Thanks a lot for your help and such a quick response! but if you see the target paginator- It has 1-15 of 40 items. So currently the code shows as 1-10 of 11. How to add this 'items'. Also the navigation arrows should get shifted to the right side.
  • Saif Ali
    Saif Ali over 5 years
    Thanks ! Is there a way to add 'items' after 1-10 of 11 ? It should look like 1-10 of 11 items
  • לבני מלכה
    לבני מלכה over 5 years
    i think you can not control it
  • Saif Ali
    Saif Ali over 5 years
    Yeah... I guess so!