We recently upgraded our angular Project from 13 to 17 and also we upgraded Angular Material to 17. But after migration Materiel 17 (MDC), we are unable to reduce the form field height.
Any help is is much appreciated.
Angular Material 13
Note: A lot of the "new" Material MDC components can/should be configured with css variables. Those can be easily found when you inspect the material element in your developer tools in your browser.
For examplethis form field has following properties in css:
You see that many of those are defined with variables and can be easily overwritten with your own custom values the same way as I demonstrated with the line-height in the example above.
2
Answers
To get rid of the padding at the bottom, you can use subscript sizing "dynamic". You can set this for the whole app via the
MAT_FORM_FIELD_DEFAULT_OPTIONS
injection token.Also you can adjust the density of the form fields, which will decrease their height. To do this for the whole app, add the following SCSS code:
For more information see the theming docs.
The only predefined height in the material form field is the
line-height
.You can change this height with a css variable called
--mat-form-field-container-text-line-height
.Check a StackBlitz with a working example here.
Note: A lot of the "new" Material MDC components can/should be configured with css variables. Those can be easily found when you inspect the material element in your developer tools in your browser.
For examplethis form field has following properties in css:
You see that many of those are defined with variables and can be easily overwritten with your own custom values the same way as I demonstrated with the line-height in the example above.