Skip to content

Commit 359c9bb

Browse files
marshall007tinayuangao
authored andcommitted
fix(input): make all icons in input containers the correct size (#3489)
* fix(input): make all icons in input containers the correct size * docs(input): add icon prefix/suffix example
1 parent 23ee633 commit 359c9bb

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

src/demo-app/baseline/baseline-demo.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99
width: 100%;
1010
}
1111

12-
.demo-icons {
13-
font-size: 100%;
14-
height: inherit;
15-
vertical-align: top;
16-
width: inherit;
17-
}
18-
1912
.demo-card {
2013
margin: 16px;
2114
}

src/demo-app/input/input-demo.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
<td>
4141
<md-input-container class="demo-full-width">
4242
<input mdInput #postalCode maxLength="5" placeholder="Postal Code" value="94043">
43-
<md-hint align="end">{{postalCode.value.length}} / 5</md-hint>
43+
<md-hint align="end">
44+
<md-icon>mode_edit</md-icon>
45+
{{postalCode.value.length}} / 5
46+
</md-hint>
4447
</md-input-container>
4548
</td>
4649
</tr></table>
@@ -51,11 +54,19 @@
5154
<md-card class="demo-card demo-basic">
5255
<md-toolbar color="primary">Prefix + Suffix</md-toolbar>
5356
<md-card-content>
57+
<h4>Text</h4>
5458
<md-input-container align="end">
5559
<input mdInput placeholder="amount">
5660
<span mdPrefix>$&nbsp;</span>
5761
<span mdSuffix>.00</span>
5862
</md-input-container>
63+
64+
<h4>Icons</h4>
65+
<md-input-container>
66+
<input mdInput placeholder="amount">
67+
<md-icon mdPrefix>attach_money</md-icon>
68+
<md-icon mdSuffix>mode_edit</md-icon>
69+
</md-input-container>
5970
</md-card-content>
6071
</md-card>
6172

@@ -152,10 +163,10 @@ <h4>Textarea</h4>
152163
<md-input-container>
153164
<input mdInput>
154165
<md-placeholder>
155-
I <md-icon class="demo-icons">favorite</md-icon> <b>bold</b> placeholder
166+
I <md-icon>favorite</md-icon> <b>bold</b> placeholder
156167
</md-placeholder>
157168
<md-hint>
158-
I also <md-icon class="demo-icons">home</md-icon> <i>italic</i> hint labels
169+
I also <md-icon>home</md-icon> <i>italic</i> hint labels
159170
</md-hint>
160171
</md-input-container>
161172
</p>

src/demo-app/input/input-demo.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
width: 100%;
99
}
1010

11-
.demo-icons {
12-
font-size: 100%;
13-
height: inherit;
14-
vertical-align: top;
15-
width: inherit;
16-
}
17-
1811
.demo-card {
1912
margin: 16px;
2013
}

src/lib/input/input-container.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ $mat-input-underline-disabled-background-image:
2727
[dir='rtl'] & {
2828
text-align: right;
2929
}
30+
31+
// Allow icons in a prefix/suffix/hint/etc to adapt to the correct size.
32+
& .mat-icon {
33+
width: auto;
34+
height: auto;
35+
font-size: 100%;
36+
vertical-align: top;
37+
}
3038
}
3139

3240
// Global wrapper. We need to apply margin to the element for spacing, but
@@ -238,12 +246,4 @@ $mat-input-underline-disabled-background-image:
238246
// Prevents the prefix and suffix from stretching together with the container.
239247
width: 0.1px;
240248
white-space: nowrap;
241-
242-
// Allow icons in a prefix/suffix to adapt to the correct size.
243-
& .mat-icon {
244-
width: auto;
245-
height: auto;
246-
font-size: 100%;
247-
vertical-align: top;
248-
}
249249
}

0 commit comments

Comments
 (0)