2

I've been using newest Angular Material in Angular 20. Trying to control stuff using mat.*-overrides but I can't find the option to change height of each mat-option inside of the form-field inside the mat-paginator. I was able to change the size of the form-field itself and color and background of the each mat-option but I cannot figure out how to change the height.

mat-options

https://imgur.com/a/dnteKEt

1 Answer 1

1

Disclaimer:

"Angular strongly discourages, and does not directly support, overriding component CSS outside the theming APIs described above. Component DOM structure and CSS classes are considered private implementation details that may change at any time." It means that if you update the version of material your styles will break. But so it's important to take that into account.

reference


So it is important to note that the styles could break after material version update. In general angular material documentation discourages this approach.


When the style in hardcoded in the CSS, there is no other way to customize it.

.mat-mdc-option {
  ...
  min-height: 48px; /* hard coded! */
  ...
}

We can try the below approach, where we define a custom class, for the dropdown of the mat-paginator using the selectConfig input.

<mat-paginator
  [length]="100"
  [pageSize]="10"
  [pageSizeOptions]="[5, 10, 25, 100]"
  aria-label="Select page"
  [selectConfig]="{panelClass: 'custom-options-size'}"
>
</mat-paginator>

Then we define the CSS which adjusts the height of the options.

.custom-options-size .mat-mdc-option {
  min-height: 20px;
}

Stackblitz Demo

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot! It worked. It is so weird that there is no option for height for that mat-option... Seems like it should be available so we can customize our stuff. They wanted to make md3 highly customizable but we can't even change the size of stuff...
The dropdown by itself can be customized, the color and font etc, but not the height, and there are no height customizations on the dropdown of the mat-paginator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.