I need to reduce the height of the mat-form-field
to 30px. (Not the just the inner element, the height of the whole mat-form-field. Any ideas?
This is a similar issue - How to change height in mat-form-field, but none of the solutions worrked properly.
You can apply the following CSS/SCSS code in the component's
.scss
or.css
file or globally in the main global.scss
or.css
file depends with your use case.sets the top padding of the .mat-form-field-infix element to 1px and also uses the !important flag to override conflicting styles.
Note that the ::ng-deep selector is used before the CSS rules, which allows the styles to be applied globally to elements inside the component's template. It is considered a deprecated technique and should be avoided in favor of other component-level styling approaches. If you need to center the text input you can also add this in your styling:
Screenshot(Before)
Screenshot after applying the css/scss styling