Skip to content

Commit ea70ca6

Browse files
committed
fix(material/form-field): inconsistent height for non-text inputs
Fixes that some non-text input variants were taller than the text ones. Fixes #26915.
1 parent afa6400 commit ea70ca6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/material/form-field/_mdc-text-field-structure-overrides.scss

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,36 @@
2020
border: none;
2121
}
2222

23+
.mat-mdc-form-field-input-control {
24+
// Due to the native input masking these inputs can be slightly taller than
25+
// the plain text inputs. We normalize it by resetting the line height.
26+
&[type='date'],
27+
&[type='datetime'],
28+
&[type='datetime-local'],
29+
&[type='month'],
30+
&[type='week'],
31+
&[type='time'] {
32+
line-height: 1;
33+
}
34+
35+
// Reduce the size of the native buttons in a date/time input,
36+
// because they can increase the height of the input (see #13317).
37+
&::-webkit-inner-spin-button,
38+
&::-webkit-calendar-picker-indicator,
39+
&::-webkit-clear-button {
40+
font-size: 0.75em;
41+
}
42+
43+
// Native datetime inputs have an element in the shadow DOM that makes them taller than
44+
// other inputs. These changes reset the user agent styles to make them consistent.
45+
// via https://8yd.no/article/date-input-height-in-safari
46+
&::-webkit-datetime-edit {
47+
line-height: 1;
48+
padding: 0;
49+
margin-bottom: -2px;
50+
}
51+
}
52+
2353
.mat-mdc-form-field .mat-mdc-floating-label.mdc-floating-label {
2454
// In order to ensure proper alignment of the floating label, we reset its line-height.
2555
// The line-height is not important as the element is absolutely positioned and only has one

0 commit comments

Comments
 (0)